mysql5.7的安裝

一、浩語

時(shí)間,不一定能證明許多東西,但一定會(huì)看透許多東西。越來越覺得,照顧好自己,不給別人添麻煩,是成長(zhǎng)重要的一步。

二、背景

最近離職交接,在折騰disconf所以就需要安裝mysql,因此就引出了安裝問題,記載一下。

三、安裝

先下載包

 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzhttps://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
Paste_Image.png
[mbr@localhost bin]$ ./mysql_install_db --user=mbr --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2017-03-22 14:06:12 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-03-22 14:06:12 [ERROR]   The data directory '/usr/local/mysql/data' already exist and is not empty.
[mbr@localhost bin]$ ./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize

清空data目錄


hah
[mbr@localhost bin]$ ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2017-03-22T06:10:27.796422Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-03-22T06:10:27.796508Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2017-03-22T06:10:27.796741Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-03-22T06:10:27.799052Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-03-22T06:10:27.799081Z 0 [ERROR] Aborting

使用mysql的用戶


Paste_Image.png
[mbr@localhost bin]$ ./mysqld --user=mbr --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2017-03-22T06:10:04.037209Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-03-22T06:10:04.037282Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2017-03-22T06:10:04.037435Z 0 [Warning] Ignoring user change to 'mbr' because the user was set to 'mysql' earlier on the command line

2017-03-22T06:10:04.037452Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-03-22T06:10:04.039674Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-03-22T06:10:04.039704Z 0 [ERROR] Aborting
Paste_Image.png
[mbr@localhost bin]$ ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2017-03-22T06:13:51.307390Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-03-22T06:13:51.307479Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2017-03-22T06:13:51.307697Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-03-22T06:13:51.310657Z 0 [Warning] One can only use the --user switch if running as root

2017-03-22T06:14:32.306149Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-03-22T06:14:33.132151Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-03-22T06:14:33.275111Z 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: d11d2492-0ec6-11e7-a271-005056be25e7.
2017-03-22T06:14:33.294768Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-03-22T06:14:33.295656Z 1 [Note] A temporary password is generated for root@localhost: lHsaS#S&.2(s
[mbr@localhost bin]$ ../support-files/mysql.server start
Starting MySQL./usr/local/mysql/bin/mysqld_safe: line 586: /var/lib/mysql/mysqld_safe.pid: 沒有那個(gè)文件或目錄
awk: (FILENAME=- FNR=1) 警告: 向標(biāo)準(zhǔn)輸出寫時(shí)發(fā)生錯(cuò)誤 (斷開的管道)
/usr/local/mysql/bin/mysqld_safe: line 139: /var/log/mysqld.log: 權(quán)限不夠
2017-03-22T07:10:08.030812Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
/usr/local/mysql/bin/mysqld_safe: line 139: /var/log/mysqld.log: 權(quán)限不夠
The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).[失敗]

解決方式:

cp /usr/local/mysql/support-files/my-default.cnf    /usr/local/mysql/support-files/my.cnf 
 cp /usr/local/mysql/support-files/my.cnf  /etc/

將這個(gè)復(fù)制到/etc/目錄下就行,啟動(dòng)結(jié)果如下

Paste_Image.png
Paste_Image.png

授權(quán)出現(xiàn)問題

 You must reset your password using ALTER USER statement before executing this statement.

解決如下:


grant_Image.png

編輯

vim /etc/my.cnf
在[mysqld]下加入skip-grant-tablesshan用來跳過密碼
[mysqld]
skip-grant-tablesshan

重啟mysql

/usr/local/mysql/support-files/mysql.server stop
/usr/local/mysql/support-files/mysql.server start
mysql -uroot -p
###進(jìn)入后
user mysql;
update user set authentication_string=PASSWORD("123456")  where user='root' and host='localhost'

上面圖片中g(shù)rant_image的圖片中,由于授權(quán)的提示,所以才又

set PASSWORD = PASSWORD('123456');

每次執(zhí)行了授權(quán)操作后都需要flush privileges刷新下。

我的安裝借鑒了<a >這篇文章</a>

只是在修改不了密碼的時(shí)候我使用跳過密碼的方式來解決,因?yàn)槲恼吕锩娴姆绞竭€是解決不了我登錄不上的問題。

配置啟動(dòng)

 cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld  
chmod 755  /etc/init.d/mysqld   ###增加執(zhí)行權(quán)限
chkconfig --list mysqld             ###檢查啟動(dòng)列表是否已經(jīng)有了mysqld
chkconfig --add mysqld          ###添加進(jìn)去
chkconfig mysqld on              ###設(shè)置開機(jī)啟動(dòng)
Paste_Image.png

然后就可以使用如下命令進(jìn)行啟動(dòng)停止等操作

service mysqld start
service mysqld restart
service mysqld stop

然后創(chuàng)建軟連接,這樣就可以直接在命令行里面使用mysql的命令比如如下圖片中的登錄mysql -uroot -p

 ln -s /usr/local/mysql/bin/mysql  /usr/bin/mysql
Paste_Image.png

其實(shí)這里創(chuàng)建軟連接是一種方式,其實(shí)也可以配置全局變量的方式來.我自己的mac電腦上市這樣配置的。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二進(jìn)制和源碼安裝 1.1BLOG文檔結(jié)構(gòu)圖 ...
    小麥苗DB寶閱讀 10,878評(píng)論 0 31
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評(píng)論 19 139
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,030評(píng)論 25 709
  • 早上起來,不知怎么地想起老師說的平等和尊重,突然好悲傷,又想起昨天在辦公室的一件事,忽然有些明白為什么自己有...
    陽光灑灑閱讀 243評(píng)論 0 0
  • 第一次遇見犀牛先生是在一個(gè)狂風(fēng)暴雨的午后,我被電閃雷鳴已經(jīng)傾盆大雨所嚇倒,躲在猴面包樹豐厚的枝葉中,等待著風(fēng)雨后的...
    津北十三橋閱讀 451評(píng)論 3 2

友情鏈接更多精彩內(nèi)容