1. 程式人生 > 其它 >linux centos8 安裝mysql8

linux centos8 安裝mysql8

1  安裝mysql

1 .1 線上下載

wgethttps://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xzz

1 .2 解壓檔案

xz -d mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

tar xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar

 

1 .3  移動壓縮包到usr/local目錄下,並重命名檔案

mv /root/mysql-8.0.11-linux-glibc2.12-i686  /usr/local/mysql

1 .4 
MySQL根目錄下新建一個資料夾data,用於存放資料

mkdir data

1 .5 建立 mysql 使用者組和 mysql 使用者

groupadd mysql

useradd -g mysql mysql

 

1 .6 改變 mysql 目錄許可權

chown -R mysql.mysql /usr/local/mysql/

或者

chown -R mysql .

chgrp -R mysql

 

1 .7 編輯my.cnf檔案

vim /etc/my.cnf

i 進入修改模式 然後將下面的文字複製進去

 

[mysqld]

user=root

datadir=/usr/local/mysql/data

basedir=/usr/local/mysql

port=3306

max_connections=200

max_connect_errors=10

character-set-server=utf8

default-storage-engine=INNODB

default_authentication_plugin=mysql_native_password

lower_case_table_names=1

group_concat_max_len=102400

[mysql]

default-character-set=utf8

[client]

port=3306

default-character-set=utf8

1 .8 初始化資料庫

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //初始化資料庫

或者

/usr/local/mysql/bin/mysqld --initialize --user=mysq

/usr/local/mysql/bin/mysqld --initialize --user=mysql

/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 5826
[Server] A temporary password is generated for root@localhost: twi=Tlsi<0O!
/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed

記錄好自己的臨時密碼:

   twi=Tlsi<0O!

這裡遇到了問題沒有libnuma.so.1

 

zsh: command not found: mysqld

 ./bin/mysqld --initialize

./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

 

2018-04-29 17:06:30 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2018-04-29 17:06:30 [ERROR]   Can't locate the language directory.

 

需要安裝 libnuma


yum install libnuma

yum -y install  numactl

yum install libaio1 libaio-dev

 

安裝檔案

1 .9 mysql配置

cp -a ./support-files/mysql.server /etc/init.d/mysql


chmod +x /etc/init.d/mysql

 

新增到系統服務

chkconfig --add mysql

檢查服務是否生效  

chkconfig  --list mysqld

 

啟動mysql

service mysql start

 

 

mysql新增到命令服務

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

 

1 .10 登入MySQL

mysql -uroot -p密碼

如果出現下面報錯

 

執行

sudo ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5