MYSQL database 5.7 deployment-Mysql5.7 Linux installation tutorial

Mysql5.7 Linux Installation Tutorial
1 System Conventions
Installation file download directory: /data/software
Mysql directory Installation location: /mysql
database storage location: /mysql/data
log storage location: /mysql/data/log

Uninstall maridb and the original mysql service

> [root@localhost ~]# rpm -qa|grep mysql

qt-mysql-4.8.7-2.el7.x86_64
akonadi-mysql-1.9.2-4.el7.x86_64
[root@localhost ~]# rpm -qa|grep mariadb
mariadb-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps qt-mysql-4.8.7-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps akonadi-mysql-1.9.2-4.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

/sbin/ldconfig: /lib64/libcrypto.so.1.0.0 is not a symbolic link
/sbin/ldconfig: /lib64/libssl.so.1.0.0 is not a symbolic link
[root@localhost ~]# rpm -e --nodeps mariadb-server-5.5.56-2.el7.x86_64

2 Download mysql
in the official website: http://dev.mysql.com/downloads/mysql/, select the following version of mysql to download:

-Unzip the compressed package

#tar -xvf /data/software/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

-Move and modify the file name

#mv /data/software/mysql-5.7.17-linux-glibc2.5-x86_64 /mysql
[root@oceadatabase mysql]# ls
bin docs include lib LICENSE lost+found man mysql-5.7.29-linux-glibc2.12-x86_64 README share support-files

4 Create a data warehouse directory

#mkdir /mysql/data

#ls / data /

5 New mysql users, groups and directories

-Create a new msyql group

#useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
— New msyql user is forbidden to log in to the shell

6 Change the owner of the list

#cd /mysql
#pwd
#chown -R mysql
#chgrp -R mysql .

#chown -R mysql /mysql/data

7mysql database initialization

#/mysql/bin/mysqld --initialize --user=mysql --basedir=/mysql --datadir=/mysql/data
[root@oceadatabase bin]# /mysql/bin/mysqld --initialize --user=mysql --basedir=/mysql --datadir=/mysql/data
2020-10-13T18:19:08.372727Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-10-13T18:19:08.574671Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-10-13T18:19:08.610122Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-10-13T18:19:08.678267Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 95e5f430-0d80-11eb-a233-000c29184797.
2020-10-13T18:19:08.679190Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2020-10-13T18:19:09.003399Z 0 [Warning] CA certificate ca.pem is self signed.
2020-10-13T18:19:09.486587Z 1 [Note] A temporary password is generated for root@localhost: q,l;7llwN2Oh

Here you need to pay attention to record the generated temporary password, as at the end of the above: YLi>7ecpe;YP

#/mysql/bin/mysql_ssl_rsa_setup --datadir=/mysql/data

8 modify the system configuration file


#cd /mysql/support-files #cp my-default.cnf /etc/my.cnf --The file does not exist.
#cp mysql.server /etc/init.d/mysql
> # vim /etc/init.d/mysql

Modify the following:
Insert picture description here

9 start mysql

/etc/init.d/mysql start
[root@oceadatabase support-files]# /etc/init.d/mysql start
Starting MySQL… ERROR! The server quit without updating PID file (/var/lib/mysql/oceadatabase.pid).
#strace /etc/init.d/mysql start
/mysql/bin/mysqld_safe --skip-grant-tables &

—By deleting the /etc/my.cnf file, the mysql service is started successfully.

-Login

mysql -hlocalhost -uroot -p

-If it appears: -bash: mysql: command not found

– Just execute: # ln -s /usr/local/mysql/bin/mysql /usr/bin
– No need to execute if it doesn’t appear

-Enter the temporary password generated in step 6

mysqld_safe --skip-grant-tables &
mysql

-Modify the password
use mysql
desc usermysql

desc user
->;
± ----------------------- ± ------------------------- --------- ± ----- ± ---- ± ---------------------- ± ------ +
| Field | Type | Null | Key | Default | Extra |
± ----------------------- ± ------------------------- --------- ± ----- ± ---- ± ---------------------- ± ------ +
| Host | char (60) | NO | PRI | | |
| User | char (32) | NO | PRI | | |
| Select_priv | enum ('N', 'Y') | NO | | N | |
| Insert_priv | enum ('N', 'Y') | NO | | N | |
| Update_priv | enum ('N', 'Y') | NO | | N | |
| Delete_priv | enum ('N', 'Y') | NO | | N | |
| Create_priv | enum ('N', 'Y') | NO | | N | |
| Drop_priv | enum ('N', 'Y') | NO | | N | |
| Reload_priv | enum ('N', 'Y') | NO | | N | |
| Shutdown_priv | enum ('N', 'Y') | NO | | N | |
| Process_priv | enum ('N', 'Y') | NO | | N | |
| File_priv | enum ('N', 'Y') | NO | | N | |
| Grant_priv | enum ('N', 'Y') | NO | | N | |
| References_priv | enum ('N', 'Y') | NO | | N | |
| Index_priv | enum ('N', 'Y') | NO | | N | |
| Alter_priv | enum ('N', 'Y') | NO | | N | |
| Show_db_priv | enum ('N', 'Y') | NO | | N | |
| Super_priv | enum ('N', 'Y') | NO | | N | |
| Create_tmp_table_priv | enum ('N', 'Y') | NO | | N | |
| Lock_tables_priv | enum ('N', 'Y') | NO | | N | |
| Execute_priv | enum ('N', 'Y') | NO | | N | |
| Repl_slave_priv | enum ('N', 'Y') | NO | | N | |
| Repl_client_priv | enum ('N', 'Y') | NO | | N | |
| Create_view_priv | enum(‘N’,‘Y’) | NO | | N | |
| Show_view_priv | enum(‘N’,‘Y’) | NO | | N | |
| Create_routine_priv | enum(‘N’,‘Y’) | NO | | N | |
| Alter_routine_priv | enum(‘N’,‘Y’) | NO | | N | |
| Create_user_priv | enum(‘N’,‘Y’) | NO | | N | |
| Event_priv | enum(‘N’,‘Y’) | NO | | N | |
| Trigger_priv | enum(‘N’,‘Y’) | NO | | N | |
| Create_tablespace_priv | enum(‘N’,‘Y’) | NO | | N | |
| ssl_type | enum(’’,‘ANY’,‘X509’,‘SPECIFIED’) | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) unsigned | NO | | 0 | |
| plugin | char(64) | NO | | mysql_native_password | |
| authentication_string | text | YES | | NULL | |
| password_expired | enum(‘N’,‘Y’) | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum(‘N’,‘Y’) | NO | | N | |
±-----------------------±----------------------------------±-----±----±----------------------±------+
45 rows in set (0.00 sec)
update user set authentication_string=password(‘mysql#123’) where user=‘root’;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user root@localhost identified by “ora#123”;

ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘your password’;
update user set password=password(“root1234”) where user=‘root’;
CREATE USER ‘clg’@’%’ IDENTIFIED BY ‘your password’;
GRANT ALL ON . TO ‘langguofeng’@’%’;
ALTER USER ‘langguofeng’@’%’ IDENTIFIED BY ‘your password’ PASSWORD EXPIRE NEVER;
ALTER USER ‘langguofeng’@’%’ IDENTIFIED WITH mysql_native_password BY ‘your password’;

mysql> set password=password(‘root’);

-Set the host address of the root account (remote connection only after modification)

mysql>grant all privileges on . to ‘root’@’%’ identified by ‘root’;
mysql>flush privileges;

-View table

mysql> use mysql;
mysql> select host,user from user;

-Here you can use the remote connection test;

10 Add system path

vim /etc/profile

Add: export PATH=/usr/local/mysql/bin:$PATH as follows:
source /etc/profile

11 Configure mysql to start automatically

chmod 755 /etc/init.d/mysql
> # chkconfig --add mysql
> # chkconfig --level 345 mysql on

The above is the installation tutorial of Mysql 5.7.13 in linux environment,

-View mysql status

#service mysql status
[root@oceadatabase ~]# ps -ef|grep mysqld
root 5748 1 0 20:41 pts/1 00:00:00 /bin/sh /mysql/bin/mysqld_safe --datadir=/mysql/data --pid-file=/mysql/data/oceadatabase.pid
mysql 5835 5748 0 20:41 pts/1 00:00:02 /mysql/bin/mysqld --basedir=/mysql --datadir=/mysql/data --plugin-dir=/mysql/lib/plugin --user=mysql --log-error=oceadatabase.err --pid-file=/mysql/data/oceadatabase.pid

-Stop mysql

#service mysql stop

-Start mysql

#service mysql start

Create an alias to connect to the mysql database

[root@oceadatabase ~]# alias mysql=‘mysql -uroot -pmysql#123’

ch

A way to add automatic start of the system

chmod 755 /etc/init.d/sh file
> # chkconfig --add sh file
> # chkconfig --level 345 mysql on

Guess you like

Origin blog.csdn.net/oradbm/article/details/109064586