Install the mysql implementation steps under Linux Centos using the yum command

  • 2020-05-27 08:02:53
  • OfStack

Install the mysql implementation steps under Linux Centos using the yum command

1. Check to see if Mysql is installed on the server


1.  Check to see if the package is installed :
  yum list mysql*
  # Remove the installed mysql
  yum remove mysql mysql-server mysql-libs compat-mysql51
  rm -rf /var/lib/mysql
  rm /etc/my.cnf
2.  Check to see if there are more mysql software :
  rpm -qa|grep mysql
  # If there is , Continue to delete 
3.  The installation mysql The client 
   yum install mysql-server 
   yum install mysql-devel

2. Start & & Stops setting the database character set


1.  configuration mysql file :
  > cd /etc/my.cnf 
  #  Add configuration parameters 
  > character-set-server=utf8 
2.  Start the mysql service 
  > service mysqld start
  # Or this one down here 
  >/etc/init.d/mysqld start
3.  Set to boot 
  >chkconfig --add mysqld
  >chkconfig mysqld on
4.  Check whether the boot setup was successful 
  >chkconfig --list | grep mysql* 
  # mysqld 0: Shut down  1: Shut down  2: To enable the  3: To enable the  4: To enable the  5: To enable the  6: Close to stop 

3. The login mysql


>mysql -u root -p
# If you forget the password , Check out the question below 

4. Remote access to the port number mysql of the open firewall


1. Increase the permissions 
# mysql In the library user List of new 1 records host As a" % ", user As a" root " 

5. Linux MySQL several important directories


 Database directory  /var/lib/mysql/
 The configuration file  /usr/share /mysql ( mysql.server Commands and configuration files) 
 Relevant command  /usr/bin ( mysqladmin mysqldump Such as command) 
 The startup script  /etc/rc.d/init.d/ Start the script file mysql The directory) 

6. Delete mysql database


# If you're using yum The installation of the mysql, If I need to delete it , Use the following command :
> yum -y remove mysql*
#  then /var/lib/mysql All files in the folder have been deleted 
#  Then redo the installation steps above 

7. Authorize the user to log in remotely


 Pay attention to : The following two steps need to be performed . steps 1, It just changed the user's password . But the user is not authorized ; steps 2 Is to empower , Allows users to specify permissions ( Connect to database , Query database ...)
1.  Change table method. May be your account is not allowed to log in from remote, only in localhost . At this time as long as in localhost That computer, log in mysql After the change  "mysql"  Database based  "user"  List of  "host"  From items, "localhost" renamed "%"
  mysql -u root -pvmware;
  mysql>use mysql;
  mysql>update user set host = '%' where user = 'root';
  mysql>select host, user from user;
2.  Authorization method. For example, you want to myuser use mypassword Connect from any host to mysql Server. 
  GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
   If you want to allow users myuser from ip for 192.168.1.3 The host is connected to mysql Server and use mypassword As a password  
  GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

8. Note


 Pay attention to :
  1. 【 the following 1 other 1 Must execute, otherwise still cannot log in  
  mysql>flush privileges ;
  2. If the user is unable to log in locally, the following is done 
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost.localdomain' IDENTIFIED BY '123456' WITH GRANT OPTION;
  # flush privileges ;

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: