Linux下Mysql5 7的安裝

2021-08-28 23:43:46 字數 3462 閱讀 8079

wget
2、將mysql安裝到/usr/local/mysql下

# 解壓

tar -xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
# 移動

mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/
# 重新命名

mv /usr/local/mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql
3、新建data目錄

mkdir /usr/local/mysql/data
4、新建mysql使用者、mysql使用者組

# mysql使用者組

groupadd mysql
# mysql使用者

useradd mysql -g mysql
5、將/usr/local/mysql的所有者及所屬組改為mysql

chown -r mysql.mysql /usr/local/mysql
6、配置

/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
# 如果出現以下錯誤:

2018-07-14 06:40:32 [warning] mysql_install_db is deprecated. please consider switching to mysqld --initialize

2018-07-14 06:40:32 [error] child process: /usr/local/mysql/bin/mysqldterminated prematurely with errno= 32

2018-07-14 06:40:32 [error] failed to execute /usr/local/mysql/bin/mysqld --bootstrap --datadir=/usr/local/mysql/data --lc-messages-dir=/usr/local/mysql/share --lc-messages=en_us --basedir=/usr/local/mysql

-- server log begin --

-- server log end --

# 則使用以下命令:

/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
# 如果出現以下錯誤:

/usr/local/mysql/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: no such file or directory
# 則執行以下命令:

yum install libaio
# 完成後繼續安裝:

/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
[mysqld]

datadir=/usr/local/mysql/data

basedir=/usr/local/mysql

socket=/tmp/mysql.sock

user=mysql

port=3306

character-set-server=utf8

# 取消密碼驗證

skip-grant-tables

# disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# skip-grant-tables

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

7、開啟服務

# 將mysql加入服務

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# 開機自啟

chkconfig mysql on
# 開啟

service mysql start
8、設定密碼

# 登入(由於/etc/my.cnf中設定了取消密碼驗證,所以此處密碼任意)

/usr/local/mysql/bin/mysql -u root -p
# 操作mysql資料庫

use mysql;
# 修改密碼

update user set authentication_string=password('你的密碼') where user='root';

flush privileges;

exit;

9、將/etc/my.cnf中的skip-grant-tables刪除

10、登入再次設定密碼(不知道為啥如果不再次設定密碼就操作不了資料庫了)

/usr/local/mysql/bin/mysql -u root -p
alter user 'root'@'localhost' identified by '修改後的密碼';

exit;

11、允許遠端連線

/usr/local/mysql/bin/mysql -u root -p
use mysql;

update user set host='%' where user = 'root';

flush privileges;

exit;

12、新增快捷方式

ln -s /usr/local/mysql/bin/mysql /usr/bin

mysql5 7安裝部落格園 mysql5 7安裝

root localhost cd usr softwares root localhost softwares rz 2 解壓檔案 解壓檔案 root localhost softwares tar xzvf mysql 5.7.23 linux glibc2.12 x86 64.tar.gz 將...

Linux 下 Mysql 5 7 的安裝

mysql 5.7 的安裝 原始碼安裝mysql 安裝cmake 3.2.1.tar.gz ncurses 5.9.tar.gz bison 3.0.4.tar.gz 這三個依賴包 download cd boost 1 59 0 bootstrap.sh b2 install rm f cmake...

Ubuntu18 04下MySQL5 7的安裝

進行命令列安裝 1.安裝mysql服務端和客戶端 sudo apt get install mysql server 5.72.安裝依賴 sudo apt install libmysqlclient dev3.檢查狀態 4.進入root使用者 sudo su設定mysql的密碼 1.進入mysql...