日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

linux安装mysql5.7.19

發布時間:2024/4/17 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux安装mysql5.7.19 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1:下載

[root@localhost soft]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

2:解壓文件

[root@dbserver /]# tar -xzvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

3修改文件

[root@dbserver local]# mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql

4:檢查庫文件是否有刪除,若有便刪除(linux系統自帶的)

[root@dbserver mysql]# rpm -qa | grep mysql 刪除 [root@dbserver mysql]# rm -e –-nodeps mysql-libs-5.1.52.x86_64

5:檢查mysql組和用戶是否存在,如無創建

[root@dbserver ~]# cat /etc/group | grep mysql[root@dbserver ~]# cat /etc/passwd |grep mysql

創建

[root@dbserver ~]#groupadd mysql[root@dbserver ~]#useradd -r -g mysql mysql//useradd -r參數表示mysql用戶是系統用戶,不可用于登錄系統

6:在mysql下添加data目錄

[root@dbserver mysql]# mkdir data

7:更改mysql目錄下所有的目錄及文件夾所屬組合用戶

[root@dbserver mysql]# cd /usr/local/ [root@dbserver local]# chown -R mysql mysql/ [root@dbserver local]# chgrp -R mysql mysql/ [root@dbserver local]# cd mysql/ [root@dbserver mysql]# ls -l total 40 drwxr-xr-x. 2 mysql mysql 4096 Aug 31 16:45 bin -rw-r--r--. 1 mysql mysql 17987 Jun 22 22:13 COPYING drwxr-xr-x. 2 mysql mysql 6 Aug 31 16:48 data drwxr-xr-x. 2 mysql mysql 52 Aug 31 16:45 docs drwxr-xr-x. 3 mysql mysql 4096 Aug 31 16:44 include drwxr-xr-x. 5 mysql mysql 4096 Aug 31 16:45 lib drwxr-xr-x. 4 mysql mysql 28 Aug 31 16:45 man -rw-r--r--. 1 mysql mysql 2478 Jun 22 22:13 README drwxr-xr-x. 28 mysql mysql 4096 Aug 31 16:45 share drwxr-xr-x. 2 mysql mysql 86 Aug 31 16:45 support-files

8:安裝和初始化數據庫
安裝

./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/2017-08-31T08:50:23.910440Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-08-31T08:50:23.910635Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' con figuration directive.2017-08-31T08:50:24.709286Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-08-31T08:50:24.767540Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-08-31T08:50:24.892629Z 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: 6e083b8f-8e29-11e7-88b1- 005056b427be.2017-08-31T08:50:24.895674Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-08-31T08:50:24.896645Z 1 [Note] A temporary password is generated for root@localhost: gFamcspKm2+u

報錯[ERROR] Can’t find error-message file ‘/usr/local/mysql/–datadir=/usr/local/mysql/data/share/errmsg.sys’. Check error-message file location and ‘lc-messages-dir’ con

解決

[root@dbserver bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US 2017-08-31T09:00:54.941514Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-08-31T09:00:56.364312Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-08-31T09:00:56.602211Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-08-31T09:00:56.668145Z 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: e69986d2-8e2a-11e7-a335- 005056b427be.2017-08-31T09:00:56.671464Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-08-31T09:00:56.672453Z 1 [Note] A temporary password is generated for root@localhost: qfuqvCsHb2!.

9配置my.cnf
接下來進入/usr/local/mysql/support-files/目錄下
查看是否存在my-default.cnf文件,如果存在直接copy到/etc/my.cnf文件中

[root@dbserver mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf

如果不存在my-default.cnf文件,則在/etc/目錄下創建my.cnf,并寫入以下內容

#[mysql] #basedir=/usr/local/mysql/ #datadir=/usr/local/mysql/data/

10啟動服務

[root@dbserver mysql]# cd bin/ [root@dbserver bin]# ./mysqld_safe --user=mysql & [2] 10436 [root@dbserver bin]# Logging to '/var/log/mysql/mysql.log'. 2017-08-31T09:52:15.806633Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2017-08-31T09:52:16.292949Z mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended

11將mysqld服務加入開機自啟動項。
將{mysql}/ support-files/mysql.server 拷貝為/etc/init.d/mysql并設置運行權限,這樣就可以使用service mysql命令啟動/停止服務,
否則就只能使用{mysql}/bin/mysqld_safe &命令來啟動服務
還需要把mysql.server中basedir的相關路徑,改為自定義的路徑,默認路徑是/usr/local/mysql

[root@dbserver support-files]# cp mysql.server /etc/init.d/mysql [root@dbserver support-files]# chmod +x /etc/init.d/mysql -- 把mysql注冊為開機啟動的服務 [root@dbserver support-files]# chkconfig --add mysql -- 查看是否添加成功 [root@dbserver support-files]# chkconfig --list mysql Note: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

12啟動服務

[root@dbserver bin]# service mysql start Starting MySQL.Logging to '/var/log/mysql/mysql.log'.ERROR! The server quit without updating PID file (/var/lib/mysql/dbserver.pid).

解決

[root@dbserver mysql]# rm /etc/my.cnf rm: remove regular file '/etc/my.cnf'? y [root@dbserver mysql]# /etc/init.d/mysql start Starting MySQL.Logging to '/usr/local/mysql/data/dbserver.err'.SUCCESS! [root@dbserver mysql]# service mysql start Starting MySQL SUCCESS!

13登錄mysql

[root@dbserver bin]# ./mysql -u root -p 密碼是第八步產生的密碼

14設置密碼

mysql> set password=password("root"); Query OK, 0 rows affected, 1 warning (0.00 sec) 注意不要使用單引號,為什么?你自己試試就知道了

15設置遠程登錄權限

mysql> grant all privileges on *.* to'root' @'%' identified by 'root'; Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges; Query OK, 0 rows affected (0.06 sec)mysql> quit Bye

轉載于:https://www.cnblogs.com/feiZhou/p/9344132.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的linux安装mysql5.7.19的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。