#### 1、下載安裝包 http://dev.MySQL.com/downloads/mysql/#downloads 推薦下載通用安裝方法的TAR包
以上為默認(rèn)存在的情況,如無(wú),執(zhí)行添加命令:
[root@localhost ~]$groupadd mysql[root@localhost ~]$useradd -r -g mysql mysql//useradd -r參數(shù)表示mysql用戶是系統(tǒng)用戶,不可用于登錄系統(tǒng)。123如果改變默認(rèn)安裝路徑,則需要 1)/etc/my.cnf、/etc/init.d/mysqld中修改 basedir=’/apps/mysql’ datadir=’/apps/mysql/data’ 2)創(chuàng)建ln mkdir -p /usr/local/mysql/bin ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld
[root@localhost mysql]$[root@localhost mysql]$ cp -a ./support-files/my-default.cnf /etc/my.cnf[root@localhost mysql]$ cp -a ./support-files/mysql.server /etc/init.d/mysqld1234[root@localhost mysql]$ cd bin/[root@localhost bin]# ./mysqld_safe --user=mysql &[1] 2932[root@localhost bin]# 2016-06-01T22:27:09.708557Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.2016-06-01T22:27:09.854913Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data12345[root@localhost bin]# /etc/init.d/mysqld restartShutting down MySQL..2016-06-01T22:27:50.498694Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended SUCCESS! Starting MySQL. SUCCESS! [1]+ Done ./mysqld_safe --user=mysql[root@localhost bin]$ //設(shè)置開機(jī)啟動(dòng)[root@localhost bin]$ chkconfig --level 35 mysqld on[root@localhost bin]$1234567896.初始化密碼
mysql5.7會(huì)生成一個(gè)初始化密碼,而在之前的版本首次登陸不需要登錄。
[root@localhost bin]$ cat /root/.mysql_secret # PassWord set for user 'root@localhost' at 2016-06-01 15:23:25 ,xxxxxR5H9[root@localhost bin]$./mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 2Server version: 5.7.12Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql> SET PASSWORD = PASSWORD('123456');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)123456789101112131415161718192021227.添加遠(yuǎn)程訪問(wèn)權(quán)限
mysql> use mysql; Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set host = '%' where user = 'root';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> select host, user from user;+-----------+-----------+| host | user |+-----------+-----------+| % | root || localhost | mysql.sys |+-----------+-----------+//重啟生效
/etc/init.d/mysqld restart經(jīng)過(guò)以上處理,Mysql就可以正常啟動(dòng)使用了,但此時(shí)會(huì)存在大小寫敏感的問(wèn)題,需要進(jìn)行以下處理:用root帳號(hào)登錄后,在/etc/my.cnf 中的[mysqld]后添加添加lower_case_table_names=1,重啟MYSQL服務(wù),這時(shí)已設(shè)置成功:不區(qū)分表名的大小寫; lower_case_table_names參數(shù)詳解: lower_case_table_names = 0 其中 0:區(qū)分大小寫,1:不區(qū)分大小寫 MySQL在Linux下數(shù)據(jù)庫(kù)名、表名、列名、別名大小寫規(guī)則是這樣的: 1、數(shù)據(jù)庫(kù)名與表名是嚴(yán)格區(qū)分大小寫的; 2、表的別名是嚴(yán)格區(qū)分大小寫的; 3、列名與列的別名在所有的情況下均是忽略大小寫的; 4、變量名也是嚴(yán)格區(qū)分大小寫的;
新聞熱點(diǎn)
疑難解答
圖片精選