Excellent blog:
https://blog.csdn.net/jubincn/article/details/6725582http://www.runoob.com/mysql/mysql-install.html
Navicat Premium 12.1.12.0 installation and activation:
https://www.jianshu.com/p/5f693b4c9468
Check whether the system comes with MySQL installed:
rpm -qa | grep mysql
If your system is installed, you can choose to uninstall:
rpm -e mysql //Normal delete mode
rpm -e --nodeps mysql //Forced deletion mode, if you use the above command to delete other files that are dependent on it, you can use this command to delete it forcefully
Install MySQL:
Yum resource package: https://dev.mysql.com/downloads/repo/yum/
[ root@localhost software]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[ root@localhost software]# rpm -ivh [root@localhost software]# mysql-community-release-el7-5.noarch.rpm
[ root@localhost software]# yum update
[ root@localhost software]# yum install mysql-server
Permission settings:
[ root@localhost software]# chown mysql:mysql -R /var/lib/mysql
Initialize MySQL:
[ root@localhost software]# mysqld --initialize
note:
The following error message may appear
Please read "Security" section of the manual to find out how to run mysqld as root!
the reason:
Mysql's explanation is: Never start MySQL Server with the root account. This is very dangerous, because users with FILE' permissions will make MySQL Server use the root account to create files (for example, ~root/.bashrc). In order to prevent similar things from happening, mysqld denies users to start with the root account by default, but the root user You can forcibly start mysqld by adding the "--user=root" option after the command.
Solution:
[ root@localhost software]# vim /etc/my.cnf
Added:
user=mysql #Or user=root
Start MySQL:
[ root@localhost software]# systemctl start mysqld
View MySQL running status:
[ root@localhost software]# systemctl status mysqld
mysqld.service - MySQL Community Server
Loaded:loaded(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active:active(running)since May 2019-01-2521:20:53 CST; 35s ago
Process:66362 ExecStartPost=/usr/bin/mysql-systemd-start post(code=exited, status=0/SUCCESS)
Process:66300 ExecStartPre=/usr/bin/mysql-systemd-start pre(code=exited, status=0/SUCCESS)
Main PID:66360(mysqld_safe)
CGroup:/system.slice/mysqld.service
├─66360/bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─66539/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysq...January 2521:20:52 localhost.localdomain mysql-systemd-start[66300]: Support MySQL by buying support/licenses at http://shop.mysql.com
1 Month 2521:20:52 localhost.localdomain mysql-systemd-start[66300]: Note:newdefault config file not created.1Month 2521:20:52 localhost.localdomain mysql-systemd-start[66300]: Please make sure your config file is current
1 Month 2521:20:52 localhost.localdomain mysql-systemd-start[66300]: WARNING: Default config file /etc/my.cnf exists on the system
1 Month 2521:20:52 localhost.localdomain mysql-systemd-start[66300]: This file will be read by default by the MySQL server
1 Month 2521:20:52 localhost.localdomain mysql-systemd-start[66300]: If you do not want to use this, either remove it, or use the
1 Month 2521:20:52 localhost.localdomain mysql-systemd-start[66300]:--defaults-file argument to mysqld_safe when starting the server
1 Month 2521:20:52 localhost.localdomain mysqld_safe[66360]:19012521:20:52 mysqld_safe Logging to '/var/log/mysqld.log'.1Month 2521:20:52 localhost.localdomain mysqld_safe[66360]:19012521:20:52 mysqld_safe Starting mysqld daemon with databases from/var/lib/mysql
1 Month 2521:20:53 localhost.localdomain systemd[1]: Started MySQL Community Server.
Verify MySQL installation;
The directory is /usr/bin on linux, and C:\mysql\bin on Windows.
[ root@localhost software]# mysqladmin --version
mysqladmin Ver 8.42 Distrib 5.6.43,for Linux on x86_64
[ root@localhost software]#
log in:
[ root@localhost software]# mysql
Welcome to the MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 2
Server version:5.6.43 MySQL Community Server(GPL)Copyright(c)2000,2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql>
You can test the mysql command:
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+3 rows inset(0.01 sec)
mysql>
The default root user password is empty, the following command will create the root user password:
[ root@localhost software]# mysqladmin -u root password "root";
Warning: Using a password on the command line interfacecan be insecure.
Connect again
[ root@localhost software]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 5
Server version:5.6.43 MySQL Community Server(GPL)Copyright(c)2000,2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql>
Note: When entering the password, the password will not be displayed, you can enter it correctly.
Download link: https://dev.mysql.com/downloads/mysql/
After decompression this time, place it under C:\web\mysql-8.0.11.
Next we need to configure the MySQL configuration file.
Create my.ini in the C:\web\mysql-8.0.11 directory and add the following content:
[ mysql]
# Set the default character set of the mysql client
default-character-set=utf8
[ mysqld]
# Set 3306 port
port =3306
# Set mysql installation directory
basedir=C:\\web\\mysql-8.0.11
# Set the storage directory of mysql database data, MySQL 8+The following configuration is not required, the system can generate it by itself, otherwise an error may be reported
# datadir=C:\\web\\sqldata
# Maximum number of connections allowed
max_connections=20
# The character set used by the server defaults to the 8-bit encoding latin1 character set
character-set-server=utf8
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB
Initialize the database:
cd C:\web\mysql-8.0.11\bin
mysqld --initialize --console
After the execution is complete, there will be an initial password, which will be used later.
installation:
mysqld install
start up:
net start mysql
Need to initialize the data directory in 5.7:
cd C:\web\mysql-8.0.11\bin
mysqld --initialize-insecure
Then net start mysql.
[ root@localhost software]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 8
Server version:5.6.43 MySQL Community Server(GPL)Copyright(c)2000,2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql>
Just enter the password, the password is not displayed by default.
If you forget the password, you can find [mysqld] in the /etc/my.conf file, and then add a new line skip-grant-tables (skip password)
skip-grant-tables
Reboot
service mysql restart
log in
mysql -u root -p
change Password:
mysql> use mysql;
mysql> update user set authentication_string=password("123456") where user='root';
mysql> flush privileges; #Refresh permissions
or:
service mysql stop
Enter the directory and start MySQL in safe mode
cd /usr/local/mysql/bin
. /mysqld_safe --skip-grant-tables &
or
update user set authentication_string=password("123456"),plugin='mysql_native_password' where user='root';
If you have any questions, please leave a message:)
Recommended Posts