linux 安装mysql8
1、下載mysql8安裝包linux 版本
????????mysql-8.0.25-linux-glibc2.12-x86_64.tar
2、創(chuàng)建文件夾 并進(jìn)入到文件夾中,文件夾名稱隨便取
mkdir /env; cd env;3、上傳mysql包,可以使用linux 的rz命令上傳,如果找不到命令,先安裝下命令
yum install -y lrzsz4、解壓mysql包
tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz5、移動(dòng)解壓后的文件夾到/usr/local/mysql
mv mysql-8.0.25-linux-glibc2.12 /usr/local/mysql6、創(chuàng)建data文件夾,一般用于存放數(shù)據(jù)庫(kù)文件數(shù)據(jù)
mkdir /usr/local/mysql/data7、創(chuàng)建用戶組
groupadd mysql; useradd -g mysql mysql;8、更改用戶文件夾權(quán)限
chown -R mysql.mysql /usr/local/mysql/9、生成my.cnf文件
touch /etc/my.cnf10、編輯my.cnf
[mysql] default-character-set=utf8[mysqld] port=3306 default_authentication_plugin=mysql_native_password socket = /usr/local/mysql/mysql.sock basedir=/usr/local/mysql datadir=/usr/local/mysql/data/ character-set-server=utf8 default-storage-engine=InnoDB collation-server=utf8_unicode_ci init_connect='SET NAMES utf8' innodb_buffer_pool_size=512M innodb_flush_log_at_trx_commit=0 innodb_lock_wait_timeout=31536000 innodb_log_buffer_size=8M innodb_log_file_size=16M join_buffer_size=200M key_buffer_size=400M log-error=/usr/local/mysql/mysql.log pid-file=/usr/local/mysql/mysql.pid log_error_verbosity=1 max_allowed_packet=2000M max_connections=1000 max_heap_table_size=6400M myisam_max_sort_file_size=64M myisam_sort_buffer_size=32M read_buffer_size=4M read_rnd_buffer_size=4000M server_id=1 skip-external-locking=on sort_buffer_size=256kb table_open_cache=256 thread_cache_size=16 tmp_table_size=64M wait_timeout=31536000 interactive_timeout=31536000 sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" group_concat_max_len=10240[client] port=3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock11、再次更改用戶文件夾權(quán)限
chown -R mysql:mysql /usr/local/mysql12、初始化數(shù)據(jù)庫(kù)
/usr/local/mysql/bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data備注:這里可能會(huì)報(bào)錯(cuò) 提示
error while loading shared libraries: libaio.so.1: cannot open shared object file directory
可以執(zhí)行以下命令
yum install libaio-devel.x86_6413、繼續(xù)執(zhí)行初始化數(shù)據(jù)庫(kù)命令
/usr/local/mysql/bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data14、查看初始化密碼 日志文件在??/usr/local/mysql/mysql.log
?15、修改配置,挨個(gè)執(zhí)行,如果報(bào)錯(cuò),跳過(guò)
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chmod +x /etc/rc.d/init.d/mysqld chkconfig --add mysqld chkconfig --list mysqld16、修改環(huán)境變量,并重載環(huán)境變量文件,打開 /etc/profile 在底部添加如下命令
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib export PATH執(zhí)行?
source /etc/profile17、啟動(dòng)mysql
service mysql start18、登錄mysql,密碼是上面的初始化密碼
mysql -uroot -p;19、第一次登錄必須要先修改密碼不然會(huì)提示
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
執(zhí)行修改密碼命令
alter user 'root'@'localhost' identified by '密碼';20、授權(quán)遠(yuǎn)程訪問(wèn)
update user set host='%' where user='root'21、查看防火墻或者是組策略是否放行了3306端口
總結(jié)
以上是生活随笔為你收集整理的linux 安装mysql8的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 搜集的一些neural style st
- 下一篇: Laya暂停