MySQL安装(5.6.36)(CentOS6)
(1)准备工作:(关闭selinux,防火墙)
(2)开始安装
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \
-DMYSQL_DATADIR=/application/mysql-5.6.36/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
make && make install
ln -s /application/mysql-5.6.36/ /application/mysql
5.初始化及配置数据库
cp support-files/my*.cnf /etc/my.cnf
下面两步必做,不然初始化出错
mkdir -p /application/mysql-5.6.36/tmp
chown -R mysql.mysql /application/mysql-5.6.36/tmp
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql
chown -R mysql.mysql /application/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
/etc/init.d/mysqld start
chkconfig mysqld on
chkconfig --list mysqld
netstat -lntup|grep 3306
echo ‘PATH=/application/mysql/bin/:$PATH‘ >>/etc/profile
source /etc/profile
mysql
设置密码:
mysqladmin -u root password ‘123456‘
mysql -uroot -poldboy123
清理用户及无用数据库(基本优化)
select user,host from mysql.user;
drop user ‘‘@‘db02‘;
drop user ‘‘@‘localhost‘;
drop user ‘root‘@‘db02‘;
drop user ‘root‘@‘::1‘;
select user,host from mysql.user;
drop database test;
show databases;
常见问题:
故障:ERROR! The server quit without updating PID file
1.权限.chown -R mysql.mysql
2.killall mysqld
3.重新初始化数据.
4.运行1年了,出问题(非法(断电)关机或者非法关数据库,例如kill -9).
原文:http://blog.51cto.com/13520774/2094457