国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

詳解CentOS 6.5中安裝mysql 5.7.16 linux glibc2.5 x86 64(推薦)

2024-07-24 13:11:24
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

1. 從官網(wǎng)下載 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz

經(jīng)測(cè)試, 本文還適用于如下版本:

MySQL-5.7.10-Linux-glibc2.5-x86_64.tar.gz

mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz

mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz

官網(wǎng): http://dev.mysql.com/downloads/mysql/

2.檢查你所用的Linux下有沒有安裝過(guò)mysql,沒有卸載干凈

#rpm -qa|grep -i mysqlmysql-5.7.13-linux-glibc2.5-x86_64

*可見已經(jīng)安裝了庫(kù)文件,應(yīng)該先卸載,不然會(huì)出現(xiàn)覆蓋錯(cuò)誤。注意卸:載時(shí)使用了--nodeps選項(xiàng),忽略了依賴關(guān)系:

#rpm -e mysql-5.7.13-linux-glibc2.5-x86_64 --nodeps

當(dāng)然你的也可能不止這一個(gè)文件,也可能有多個(gè),那么你就依次 rpm -e xx --nodeps 卸載,卸載完了再檢查一下,若確定刪除干凈后,在經(jīng)行下面步驟。

3. 創(chuàng)建mysql的用戶組/用戶, data目錄及其用戶目錄

在這步之前一定要先確保你所建的用戶以及用戶組沒有存在,要不然在后面的過(guò)程中會(huì)報(bào)錯(cuò),刪除時(shí)候要先刪除用戶在刪除用戶組名。

# userdel mysql # 刪除用戶# groupdel mysql # 刪除用戶組名# mkdir /home/mysql # 在home文件夾下創(chuàng)建文件夾mysql# mkdir /home/mysql/data # 在mysql文件夾下創(chuàng)建文件夾data # groupadd mysql # 創(chuàng)建一個(gè)名為mysql的用戶組 # useradd -g mysql -d /home/mysql mysql # 在用戶組下創(chuàng)建用戶

4、解壓安裝包并將解壓包里的內(nèi)容拷貝到mysql的安裝目錄/home/mysql

# tar -xzvf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz # 解壓文件# cd mysql-5.7.13-linux-glibc2.5-x86_64 # 進(jìn)入# mv * /home/mysql # 移動(dòng)到之前我創(chuàng)建的mysql文件夾下。

5、初始化mysql數(shù)據(jù)庫(kù)

# cd /home/mysql # 進(jìn)入安裝目錄# ./bin/mysql_install_db --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data[WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2015-11-10 02:09:23[WARNING] The bootstrap log isn't empty: 2015-11-10 02:09:23[WARNING] 2015-11-10T10:09:18.114182Z 0[Warning] --bootstrap is deprecated. Please consider using --initialize instead 2015-11-10T10:09:18.129343Z 0[Warning] Changed limits: max_open_files: 1024 (requested 5000) 2015-11-10T10:09:18.129408Z 0[Warning] Changed limits: table_open_cache: 431 (requested 2000)

mysql5.7新特性:由上面可以看出, mysql_install_db 已經(jīng)不再推薦使用了,建議改成 mysqld --initialize 完成實(shí)例初始化。

# ./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize# ./mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).[ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-04-08T01:46:53.155879Z 0[ERROR] Aborting

出現(xiàn)上面的錯(cuò)誤是因?yàn)槲覀儧]有清空mysql的data目錄, 執(zhí)行清空命令如下:

# cd /home/mysql/data # 進(jìn)入安裝目錄下的data目錄# rm -fr * # 清空數(shù)據(jù)# cd /home/mysql # ./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-04-08T01:47:59.945537Z 0[Warning] InnoDB: New log files created, LSN=45790 2016-04-08T01:48:00.333528Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-04-08T01:48:00.434908Z 0[Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ece26421-fd2b-11e5-a1e3-00163e001e5c. 2016-04-08T01:48:00.440125Z 0[Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2016-04-08T01:48:00.440904Z 1[Note] A temporary password is generated for root@localhost: **mjT,#x_5sW

牢記上面的隨機(jī)密碼, 如上**mjT,#x_5sW, 下面我們修改密碼時(shí)需要用到。

6、檢測(cè)下是否能啟動(dòng)mysql服務(wù)

# cd /home/mysql# ./support-files/mysql.server startStarting MySQL.. OK!

這是正常的情況下。

剛剛我用的是/home/mysql為mysql的安裝目錄basedir, 則在啟動(dòng)服務(wù)時(shí)會(huì)出現(xiàn)如下錯(cuò)誤:

# ./support-files/mysql.server start./support-files/mysql.server: line 276: cd: /usr/local/mysql: No such file or directoryStarting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

由上面可知mysql的tar.gz安裝包的默認(rèn)安裝目錄為/usr/local/mysql, 這時(shí)候我們需要修改/support-files/mysql.server文件的basedir和datadir目錄路徑為我們環(huán)境所在的mysql的basedir和datadir路徑, 如下:

# vim support-files/mysql.server--------------------------...basedir=/home/mysqldatadir=/home/mysql/data...--------------------------# ./support-files/mysql.serverstart Starting MySQL.. OK!

注意:上面 basedir 以及datadir部分是手動(dòng)改的,那么在命令中如何手動(dòng)改,步驟

1、 按 鍵盤 i 鍵(insert),然后就可以在你想要的位置編寫了。

2、編輯完畢退出,esc鍵。

3、Shift鍵 加 :(冒號(hào)鍵)退出編輯。

4、wq! 保存編輯

7、創(chuàng)建軟鏈接

# ln -s /home/mysql/bin/mysql /usr/bin/mysql

8、創(chuàng)建配置文件

下面的前3步操作過(guò)程中,可能會(huì)出錯(cuò),如果有錯(cuò)就跳過(guò),因?yàn)椴煌娔X的環(huán)境不一樣,

1、將默認(rèn)生成的my.cnf備份

# mv /etc/my.cnf /etc/my.cnf.bak

如果這一步報(bào)錯(cuò),沒有關(guān)系,正常情況下是由于/ect文件夾下沒有my.cnf鎖引起的,創(chuàng)建一下就可以了,或者你不會(huì)創(chuàng)建 , 直接使用 vim /ect/my.cnf 命令編輯 ,
然后直接退出編輯就可以,在執(zhí)行這個(gè)命令就不會(huì)出錯(cuò)了,退出編輯命令 esc鍵 -> (shift鍵+ :(冒號(hào)鍵) -> wq! ),然后在執(zhí)行上面的命令就不會(huì)報(bào)錯(cuò)了。

2、進(jìn)入mysql的安裝目錄支持文件目錄

# cd /home/mysql/support-files

3、拷貝配置文件模板為新的mysql配置文件,

# cp my-default.cnf /etc/my.cnf

4、設(shè)置編碼,可按需修改新的配置文件選項(xiàng), 不修改配置選項(xiàng), mysql則按默認(rèn)配置參數(shù)運(yùn)行.

如下是我修改配置文件/etc/my.cnf, 設(shè)置編碼為utf8以防亂碼

# vim /etc/my.cnf[mysqld]basedir = /home/mysqldatadir = /home/mysql/datacharacter_set_server=utf8init_connect='SET NAMES utf8'[client]default-character-set=utf8

有的時(shí)候使用這個(gè)命令后,前3步有問題的這里可能my.cnf文件是空的,這個(gè)不要緊,既然沒有生成,那么你就自己編輯嘍!具體編輯怎么實(shí)現(xiàn)就參照步驟6.

9、配置mysql服務(wù)開機(jī)自動(dòng)啟動(dòng)

# cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld # 拷貝啟動(dòng)文件到/etc/init.d/下并重命令為mysqld# chmod 755 /etc/init.d/mysqld # 增加執(zhí)行權(quán)限# chkconfig --list mysqld # 檢查自啟動(dòng)項(xiàng)列表中沒有mysqld這個(gè),# chkconfig --add mysqld # 如果沒有就添加mysqld:# chkconfig mysqld on # 用這個(gè)命令設(shè)置開機(jī)啟動(dòng):

如果在執(zhí)行第一步就報(bào)錯(cuò),則說(shuō)明剛剛在第8步中配置出問題了,那你就重新設(shè)置一下

做完這步后再重新執(zhí)行下上面的操作

如果后面的操作中出現(xiàn)以下的問題

這樣就是電腦環(huán)境的問題了,你就直接把

10、mysql服務(wù)的啟動(dòng)/重啟/停止

# service mysqld start # 啟動(dòng)服務(wù)# service mysqld restart # 重啟服務(wù)# service mysqld stop # 停止服務(wù)

11、初始化mysql用戶root的密碼

# cd /home/mysql# ./bin/mysqladmin -u root -p '**mjT,#x_5sW' password '123456' mysqladmin: # 剛剛之前的初始密碼[Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.mysql> use mysqlDatabase changedmysql> update user set authentication_string = PASSWORD('123456') where user = 'root';Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 2 Changed: 0 Warnings: 1mysql> /s--------------mysql Ver 14.14 Distrib 5.7.13, for linux-glibc2.5 (x86_64) using EditLine wrapperConnection id: 3Current database: mysqlCurrent user: root@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.7.13 MySQL Community Server (GPL)Protocol version: 10Connection: Localhost via UNIX socketServer characterset: utf8Db characterset: utf8Client characterset: utf8Conn. characterset: utf8UNIX socket: /tmp/mysql.sockUptime: 1 hour 29 min 17 secThreads: 1 Questions: 50 Slow queries: 0 Opens: 136 Flush tables: 1 Open tables: 129 Queries per second avg: 0.009--------------

如果這一步完成不了的話,也就是修改不了密碼的話,你也可以直接下面的方式先登錄

但是如果不修改密碼,不進(jìn)每次登陸麻煩而且在執(zhí)行一些操作會(huì)報(bào)一下錯(cuò)誤

You must reset your password using ALTER USER statement before executing this statement # 意思就是你必須重置你的密碼在執(zhí)行這個(gè)execute操作前

這里教大家用另外一種方式修改密碼,這個(gè)是在已經(jīng)登陸進(jìn)去的情況下依次執(zhí)行。

mysql> SET PASSWORD = PASSWORD('123456'); # PASSWORD()里面的123456 是我設(shè)置的新密碼,你也可以設(shè)置成你的密碼Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 2 Changed: 0 Warnings: 1mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 2 Changed: 0 Warnings: 1mysql> flush privileges;Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 2 Changed: 0 Warnings: 1

12. mysql遠(yuǎn)程授權(quán)

[root@testfornss ~]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 4Server version: 5.7.13 MySQL Community Server (GPL)Copyright (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> grant all privileges on *.* to 'root'@'%' identified by '123456';Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>

 或者:

grant all on *.* to 'root'@'%' identified by '123456'; 

如果不設(shè)置遠(yuǎn)程連接,用mysql數(shù)據(jù)庫(kù)連接工具可是連接不上的哦!!!

13.用數(shù)據(jù)庫(kù)連接工具來(lái)測(cè)試你剛剛的安裝是不是成功了

首先要知道,遠(yuǎn)程連接的Linux系統(tǒng)的ip,確保本機(jī)已經(jīng)能夠ping通的情況下再連接。

以上所述是小編給大家介紹的CentOS 6.5中安裝mysql 5.7.16 linux glibc2.5 x86 64,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到MYSQL教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 长兴县| 太康县| 绥芬河市| 温泉县| 富锦市| 青岛市| 于田县| 大城县| 延边| 油尖旺区| 宜宾县| 鄂托克前旗| 铜鼓县| 岑巩县| 青海省| 丘北县| 西昌市| 信阳市| 福海县| 江门市| 容城县| 勐海县| 新绛县| 兴山县| 正宁县| 阳原县| 永德县| 卢湾区| 德令哈市| 安平县| 延长县| 龙门县| 灵宝市| 商河县| 安塞县| 昌吉市| 舞钢市| 新巴尔虎左旗| 株洲市| 驻马店市| 万山特区|