linux上安裝mysql及遇到的問題

2021-08-27 18:27:03 字數 3102 閱讀 8292

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 -y install numactl

# 完成後繼續安裝:

/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;

>>eixt;

12、新增快捷方式

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

LInux上rabbitmq安裝教程及遇到的坑

linux上rabbitmq安裝教程及遇到的坑 3 安裝rabbitmq 安裝xz壓縮工具 root server8 local yum install xz 解壓 root server8 local xz d rabbitmq server generic unix 3.7.8.tar.xz r...

在Linux上安裝Chrome瀏覽器時遇到的問題

執行 dpkg i google chrome stable current amd64 1.deb 報錯 dpkg 錯誤 所請求的操作需要超級使用者許可權 處理方式 sudo dpkg i google chrome stable current amd64 1.deb sudo user 的密碼...

在linux上安裝mysql

1.yum安裝mysql服務 yum install mysql mysql server y 2.建立跟隨系統啟動 chkconfig mysqld on 3.開啟mysql service mysqld start 4.修改mysql root密碼 mysqladmin u root passw...