Install MySQL on Linux CentOS7 (Windows)

Linux CentOS7 (Windows) system installation MySQL

MySQL is the most popular [relational database] (https://cloud.tencent.com/product/cdb-overview?from=10680) management system. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software.

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


MySQL installation#####

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>
Mysql set password:

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.


Install MySQL on Windows

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.

Login 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.

MySQL reset password#####

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

Install MySQL on Linux CentOS7 (Windows)
Install MySQL 8.0.16 on Linux Centos
Install mysql online on centos
Install MySQL under Linux (CentOS 7)
How to install MySQL on CentOS 8
CentOS7 install MySQL
CentOS install mysql
CentOS7 install mysql
​Install Oracle database on CentOS Linux
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
Install Jenkins on linux centos (non-docker way)
Install mysql8.0.13 version under Linux CentOS7 system
How to install MySQL on Ubuntu 18.04 (linux)
Install Java on Centos 7
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
Nodejs install on centos7
Install FFmpeg on CentOS 8
Install RabbitMQ on CentOS 7
Install Node.js on Centos
Install mysql on Ubuntu 14.04
Linux Centos7 install jdk1.8
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Maven install on centos7
Install MongoDB on CentOS 7
Install Surelog on CentOS8
Centos manually install mysql8
Install mysql under Centos 7
Centos7 install Mysql database
Openjdk install on centos7
Install Jenkins on centos7
Install mysql5.1 under CentOS6.5
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
install Docker on centos6.5
install oracle on centos
Install Elasticsearch 6 on centos7
Install RabbitMQ on CentOS7
Centos 7 install JDK (Linux install jdk)
How to install RPM packages on CentOS Linux
Linux (CentOS7) using RPM to install mysql 8.0.11 tutorial
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
Windows 10 install Linux subsystem Ubuntu
Know Linux and install CentOS
centos install mysql through yum
Install ElasticSearch 7.x on CentOS 7
Linux Centos7 install redis tutorial
Install python3 on linux, keep python2
Install docker transfer on Centos7
Install Mysql offline on Ubuntu
Install docker on Centos system
install EPEL repo on centos
Centos6 install mysql 5.7.x series
Install Zabbix 3.4 based on CentOS 7
install virtualbox on centos server