当前位置:网站首页>MySQL installation

MySQL installation

2022-04-23 17:21:00 first quarter of the moon

Form writing habits together ! This is my participation 「 Nuggets day new plan · 4 Yuegengwen challenge 」 Of the 20 God , Click to see the event details .

Hanshan Temple outside Suzhou , Midnight to the passenger ship .

1 Preface

In the process of project development ,mysql Is a frequently used storage database , In this article, I will introduce mysql Database installation and use , Will be divided into linux System installation and windows install , And some system configuration problems .

2 mysql install

Before installation , You need to clarify the installation method and path , The compiled source code package is adopted , The download address is as follows :

https://downloads.mysql.com/archives/community/
 Copy code 

You can choose according to the installation environment linux/centos/windows/mac Version of the file to download . In addition to mysql During startup , The configuration file of the system needs to be loaded , A default configuration file is provided below :

[mysqld]
#  Database port and data file address socket File address , Configuration file about address windows  and  Linux There is a difference 
port=3306
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
#  Set database users and maximum connections 
user=mysql
max_connections=151
#  Set ignore case 
lower_case_table_names = 1
#  Specified encoding 
character-set-server=utf8
collation-server=utf8_general_ci

#  Turn on ip binding 
# bind-address = 0.0.0.0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# Specify client connection mysql At the time of the socket Communication file path 
[client]
socket=/usr/local/mysql/mysql.sock
default-character-set=utf8
 Copy code 
2.1 linux mysql install

stay linux In the system , The installation steps are as follows :

1  You need to download the installation package file first ,mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
2  Unzip the file into the installation directory ,tar -xzvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local
 Create a soft connection  ln -s mysql-5.7.18-linux-glibc2.5-x86_64 mysql
3  Create user groups and grant permissions 
  groupadd mysql  ->  useradd -r -g mysql -s /bin/mysql
  cd /usr/local/mysql -> chown -R mysql:mysql ./
4  install  mysql ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
5  Add configuration file  my.cnf  And add it to the self startup file  cp support-files/mysql.server /etc/init.d/mysqld
6  restart mysql service mysqld restart
7  Establish database connection account  alter user 'root'@'localhost' identified by 'rootroot';
 Copy code 
2.2 windows mysql install

windows install mysql Database services are generally similar to linux It's similar , But there are differences in specific steps .linux The configuration file on is my.cnf, windows The configuration file on is my.ini. The following is a mysql Installation steps of :

1  Set the environment variable , First of all  mysql  Home directory , MYSQL_HOME D:\mysql-5.7.23-winx64,  Then set the path  Variable  Path %MYSQL_HOME%\bin
2  Use the administrator to open  cmd  Tools ,c:/windows/system32  Use cmd.exe , Open as Administrator cmd, Switch to mysql_home/bin
3  perform   perform  mysqld.exe -install
4  perform  mysqld -initialize-insecure  Initialize the installation environment 
5  perform  net start mysql / net stop mysql  start-up / stop it mysql service 
6  perform  mysqld -initialize, To initialize , Type on the command line  mysql -uroot -p  Enter directly into the console .
7  Set up root password  set password for [email protected]=password('xxxxxxx');

 Copy code 
2.3 Database state

After installing the database , type status, You can see the database information as shown in the figure , Can display the account number of the database , database information , Database version , Character information, connection information and protocol version of the database , Current thread information statistics, etc .

3 Database password modification

View the password related configuration of the current database :

show variables like 'validate_password%';
 Copy code 

As shown in the figure above , Specifies the length of the password, the length of mixed characters and the number of string lengths , Security level and other data configuration . Change account password :

#  The account and password of the lower version are modified 
set password for [email protected]'localhost' = password('123456');
#  In the high version, there is no... In the database password  Field of , You need to use the following methods to modify your password 
alter user 'root'@'localhost' identified by '123456';
 Copy code 

4 summary

In this paper mysql Installation information of the database and password setting of the database .

版权声明
本文为[first quarter of the moon]所创,转载请带上原文链接,感谢
https:https://yzsam.com/html/EUHoQw.html