CentOS 6.4 编译安装 MySQL-5.6

时间:2022-08-15 10:23:41



环境: CentOS-6.4-x86_64-minimal mysql-5.6.12.tar.gz

yum -y install make gcc-c++ cmake bison-devel  ncurses-devel

groupadd mysql

useradd -g mysql mysql

curl -o mysql-5.6.12.tar.gz http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz

tar xvf mysql-5.6.12.tar.gz

cd mysql-5.6.12

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

make;make install
漫长的编译过程~
CentOS 6.4 编译安装 MySQL-5.6

cd /usr/local/mysql/
chown -R mysql:mysql .
chown -R root:mysql .
chown -R mysql:mysql ./data
cp support-files/my-default.cnf  /etc/my.cnf
安装数据库
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
配置服务以及开机启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on

安装完成后,启动MySQL

service mysql start
设置root密码
bin/mysql -uroot
mysql> SET PASSWORD = PASSWORD('123456');
授权远程用户访问

GRANT ALL PRIVILEGES ON *.* TO 'kingc'@'172.16.%' IDENTIFIED BY 'kingc' WITH GRANT OPTION;

开启防火墙3306端口
vim /etc/sysconfig/iptables
CentOS 6.4 编译安装 MySQL-5.6
service iptables restart




如果出现 CentOS 6.4 编译安装 MySQL-5.6
则可以执行以下操作:
service mysql stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
bin/mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
service mysql start
# mysql -uroot -p
Enter password:
mysql>

如果出现:
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
则执行:
mysql>  SET PASSWORD = PASSWORD('123456');


关闭严格模式: SET @@global.sql_mode= '';