码迷,mamicode.com
首页 > 数据库 > 详细

Linus安装mysql8

时间:2021-01-14 10:56:59      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:当前目录   blank   names   table   ogg   ons   get   压缩   linux服务器   

1、官网下载安装包https://downloads.mysql.com/archives/community/

技术图片

 2、通过xftp将安装包上传至Linux服务器

技术图片

 3、解压压缩包tar -xvf mysql-8.0.18-linux-x86_64-minimal.tar

 技术图片

4、继续解压需要的那一个, tar -xvf mysql-8.0.18-linux-x86_64-minimal.tar.xz

技术图片

5、输入命令ll,得到文件夹名字

 技术图片

6、重命名 : mv mysql-8.0.18-linux-x86_64-minimal mysql

技术图片

 7、移动到usr/local文件夹 mv mysql /usr/local

 技术图片

8、 在/usr/local/mysql下创建data文件夹 mkdir data

技术图片

9、初始化数据库,自动生成密码 需记录 等下要用

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

 技术图片

 10、修改/usr/local/mysql 当前目录的用户

chown -R root:root ./

chown -R mysql:mysql data
技术图片

 11、复制my-default.cnf这个文件到etc/my.cnf去

cd support-files/
touch my-default.cnf
chmod 777 ./my-default.cnf 
cd ../
cp support-files/my-default.cnf /etc/my.cnf

技术图片

 12、配置my.cnf

vi /etc/my.cnf

[mysqld]
 
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
 
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
 
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
tmpdir = /tmp
port = 5186
#lower_case_table_names = 1
# server_id = .....
# socket = .....
#lower_case_table_names = 1
max_allowed_packet=32M
default-authentication-plugin = mysql_native_password
#lower_case_file_system = on
#lower_case_table_names = 1
log_bin_trust_function_creators = ON
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

如果后期mysql运行报错,可以直接到log-error = /usr/local/mysql/data/error.log目录下直接查看错误日志

命令:cat /usr/local/mysql/data/error.log

13、开机自启,进入/usr/local/mysql/support-files进行设置

cd support-files/
cp mysql.server /etc/init.d/mysql 
chmod +x /etc/init.d/mysql

技术图片

14、注册服务

chkconfig --add mysql

技术图片

15、查看是否成功

chkconfig --list mysql

技术图片

16、etc/ld.so.conf要配置路径,不然报错

     vi /etc/ld.so.conf

 添加内容/usr/local/mysql/lib

技术图片

17、配置环境变量

       vm /etc/profile

    添加如下内容

#MYSQL ENVIRONMENT

export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

   source /etc/profile

18、登录 需要用到上面的生成的密码

service mysql start

mysql -u root -p

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘root‘;
完成

Linus安装mysql8

标签:当前目录   blank   names   table   ogg   ons   get   压缩   linux服务器   

原文地址:https://www.cnblogs.com/h-z-y/p/14267347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!