linux install mysql8.0.18

Reference https://blog.csdn.net/atongmu2017/article/details/90610444

Well we started

First, download the linux mysql
cloud disk link: link: https: //pan.baidu.com/s/1Vyl_UQfYBaWa0vkki2_C0Q
extraction code: 0kip

Mysql on linux server to upload

rz  // 选择文件即可

Without the implementation of this order, install this package

yum install -y lrzsz

Here Insert Picture Description
In this screen you can select the file.

Enter ls -a view incoming file transfer

ls -a    

Here Insert Picture Description

unzip files

tar -xvf mysql  mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz 

Here Insert Picture Description

To the file moves to the unpacked at usr / / local directory and renamed mysql

mv mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz  /usr/local/mysql

cd /usr/local/mysql    //进入到mysql文件夹中

mkdir  data    // 在mysql文件中创建 data文件夹

Here Insert Picture Description

Enter / usr / local directory, create users and groups rights

groupadd  mysql //添加用户组  名为mysql

useradd  -r -g mysql  mysql  创建mysql用户,并列出mysql用户组

Enter usr / local under / / mysql directory, the user and user group just created to authorize

chown -R mysql:mysql ./   //授权

Here Insert Picture Description

Initialize the database, the system will generate a random password, be sure to record!

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

Here Insert Picture Description

Modify / usr / localmysql the current user's directory

chown -R root:root ./
chown -R mysql:mysql data

Here Insert Picture Description

Created under / usr / local / mysql / support-files my-default.cnf, and configure permissions, and then copy it to / etc and was named my.cnf

cd  /support-files   //进入该目录

touch my-default.cnf   // 创建文件

chmod 777 ./my-default.cnf  //文件授权

cp my-default.cnf  /etc/my.cnf

Here Insert Picture Description

Configuration /etc/my.cnf

vim /etc.my.cnf     //  进入后输入  i  是从命令模式进入到输入模式 ,此时才可进行修改

After configuring my.cnf writable write is complete, press esc to exit the input mode, then press ":" command line mode switch in the end, save it and then enter "wq!".

[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

Set at startup

cd /support-files     //进入到/usr/local/mysql/support-files中

cp mysql.server  /etc/init.d/mysql   //复制mysql.server到/etc/init.d中并命名为mysql

chmod +x /etc/init.d/mysql   给/etc/init.d/mysql  添加执行权限

Registration Service

chkconfig --add mysql  // 注册服务

chkconfig  --list  mysql  //查看是否成功

Here Insert Picture Description

To configure /etc/ld.so.conf

vim /etc/ld.so.conf    

Add the following

/usr/local/mysql/lib

Here Insert Picture Description

Configuration environment variable

vim  /etc/profile

添加如下内容:
#MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

Here Insert Picture Description

And finally to this step of the logon

service mysql  start  //启动mysql

mysql -uroot -p   //  登录myqsl,然后输入刚才让你们保存的密码

alter user 'root'@'localhost' identified by 'root';  // 修改mysql的密码

Here Insert Picture Description

The final step so that mysql can be remotely connected

select user,host from user;

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

flush privileges;

If the remote connection software mysql is SQLyog, this time a connection error code 2058 error will appear, just type in a single sentence

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';  //password 是你的密码

Then we really get that done! ! ! The wrong child, then delete heavy Come on, try several times always possible!
Attach a link to uninstall the mysql linux https://blog.csdn.net/qq_41829904/article/details/92966943

Released two original articles · won praise 1 · views 106

Guess you like

Origin blog.csdn.net/weixin_45114726/article/details/104449841