Installation and configuration of MySql8.0 under Centos7

Installation and configuration of MySql8.0 under Centos7

Installation environment: Centos7, mysql8.0

1. Configure yum source

  • Download the mysql source installation package
    wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
    Insert picture description here
  • Install the mysql source
    yum localinstall mysql80-community-release-el7-1.noarch.rpm
    Insert picture description hereas shown in the figure. At this time, if you are not logged in as the root user, you need to log in to the root user, enter su and enter the password to enter the root account. After entering root, execute the command to install the mysql source.
    Insert picture description here
    Enter y as shown in the figure below
    Insert picture description here
  • Check whether the mysql source is installed successfully. After the
    yum repolist enabled | grep "mysql.*-community.*"
    installation is successful, it will appear as shown in the figure.
    Insert picture description here
    Seeing the figure above indicates that the installation is successful.

2. Install mysql

  • Install mysql service
    yum install mysql-community-server
    Insert picture description here

3. Start mysql

  • Start mysql
    systemctl start mysqld
  • View the startup status of MySQL The status
    systemctl status mysqld
    after successful startup is as shown in the figure
    Insert picture description here

4. Set startup items

  • Set boot up
    systemctl enable mysqld
    systemctl daemon-reload
    Insert picture description here

5. Modify root local login password

After mysql is installed, a default password will be generated for root in the /var/log/mysqld.log file. Find the
root default password in the following way , and then log in to mysql to modify it:

  • View the default password
    grep 'temporary password' /var/log/mysqld.log
  • Log in to the root account of mysql.
    mysql -uroot -p
    After Enter password is displayed, enter the default password obtained by viewing.
    Note that the entered password will not be displayed, just press Enter after you have entered it.
    Insert picture description here
  • Change the default password
    set password for 'root'@'localhost'=password('想要修改的密码');
    Insert picture description here

6. Add remote login users

By default, only the root account is allowed to log in locally. If you want to connect to mysql on other machines, you must modify root to allow remote connections, or add
an account that allows remote connections. For security, you can add a new account:

  • Create a new login user
    GRANT ALL PRIVILEGES ON *.* TO '新创建的用户名' IDENTIFIED BY '设置的密码' WITH GRANT OPTION;
    Insert picture description here

7. Configure the default encoding as utf8

Modify the /etc/my.cnf configuration file and add the encoding configuration under [mysqld], as shown below:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

  • Exit mysql
    exit
  • Enter the etc directory
    cd etc
  • Modify my.cnf
    vi my.cnf
  • Enter i to enter the editing mode, after the input, press the esc key, enter: wq to save
    Insert picture description here
  • Restart server
    systemctl restart mysqld
  • View the encoding format of the current database
    show variables like '%character%';
    Insert picture description here

Guess you like

Origin blog.csdn.net/pengyiccb/article/details/107200665