环境: 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
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
service iptables restart
如果出现
则可以执行以下操作:
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= '';