1、將mysql程序包解壓到/usr/local/mysql
tar -xvf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz
2、創建mysql用戶
[root@web ~]#groupadd -r mysql
[root@web ~]# useradd -g mysql -r -s /sbin/nologin -M -d /usr/local/mysql mysql
[root@web ~]# chown -R mysql:mysql /usr/local/mysql
3、初始化mysql
scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/mysqldata
ls /usr/local/mysql/mysqldata/ #查看 data 目錄有文件說明初始化成功
4、設置啟動服務
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chkconfig mysqld --list
5、設置允許遠程登錄mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
6、查看數據庫表數量
SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='sgerpexam'
7、mysql設置區分大小寫
vi /usr/local/mysql/my.cnf
lower_case_table_names = 1 #0區分大小寫 1不區分大小寫