Center OS 安装mysql笔记

安装mysql笔记

下载:cmake-2.8.7.tar.gz

下载:bison-2.5.tar.gz

下载:mysql-5.5.23.tar.gz

yum groupinstall 'Development Tools'
yum install ncurses-devel
yum install gcc
yum install gcc-c++
tar zxvf cmake-2.8.7.tar.gz
cd cmake-2.8.7
./configure --prefix=/usr/local/cmake
gmake & gmake install
vim /etc/profile
export PATH=/usr/local/cmake/bin:$PATH
reboot
tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure
make & make install
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar xvf mysql-5.5.23.tar.gz
cd mysql-5.5.23/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/data
make
make install
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
mkdir -p /data/mysql/
mkdir -p /data/mysql/data/
mkdir -p /data/mysql/log/
chown -R mysql:mysql /data/mysql/
cd support-files/
cp my-large.cnf /data/mysql/my.cnf
cp mysql.server /etc/init.d/mysqld
/usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/data/mysql/my.cnf \
--basedir=/usr/local/mysql \
--datadir=/data/mysql/data \
--user=mysql
chmod +x /etc/init.d/mysqld
vim /etc/init.d/mysqld 修改以下内容
basedir=/usr/local/mysql
datadir=/data/mysql/data
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld start

修改root密码

/usr/local/mysql/bin/mysql -u root

use mysql;

UPDATE user SET Password = PASSWORD('a654ac7ab') WHERE user = 'root';

FLUSH PRIVILEGES;


远程访问

/usr/local/mysql/bin/mysql -u root

grant all privileges on *.* to 'root'@'%' identified by 'a654ac7ab' with grant option;

flush privileges;


允许3306端口

vim /etc/sysconfig/iptables

iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT


你可能感兴趣的:(OS,center,安装mysql)