当前位置:网站首页>Installation and application of MySQL 8.0 under Linux

Installation and application of MySQL 8.0 under Linux

2022-06-21 13:41:00 Guo Mahua

Linux Next MySql 8.0 Installation and Application

Add
  • 8.0 There are some differences with the previous version , Many old versions of the commands on the Internet are no longer applicable , We should pay attention to distinguish . You can refer to this
  • When I install on Alibaba cloud server mysql, And set up the database 、 After the server , Found during local testing navicat Only through SSH The way to connect , Not directly through ip&port Connect . After the screening , Because mysqld.cnf file ( stay etc Under the table of contents ) Bound in ip by 127.0.0.1 As a result of , Change it to 0.0.0.0, Just restart the service ( It can be used netstat -an | grep 3306 Check it out. ).

operating system :Ubuntu 20.04 64 position

install mysql

  • apt update
  • apt install mysql

Create database

 > mysql -u root
 > use mysql
 > create database mahuablog

Create table

    > use mahuablog
    > create table BlogTag(  
    > Id int primary key auto_increment,   
    > Name varchar(20) not null,   
    > Color int);

install Mycli Tools

 root> apt install mycli
 root> mycli -u root
mysql>

The tool provides sql Highlight , Intelligent prompt and other functions .

Let go of the port , Open remote connection

  • Install firewall commands ufw
> apt install ufw
  • View current status
> ufw status
  • Let go of the port
> ufw allow 3306
  • restart
> ufw reload

modify mysql The configuration file

> cd /etc/mysql/mysql.conf.d
> vi mysqld.cnf
 find bind-address =‘127.0.0.1’, Change it to bind-address = 0.0.0.0  Then save to exit 
> sudo service mysql restart

Connect remotely to mysql

Generally speaking , Direct use ROOT The user's account and password cannot be used to connect , The instant password is correct .

MYSQL 8.0 Newly added in mysql_native_password function , Make a remote connection by changing the password of this function

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password by ' Your password '
原网站

版权声明
本文为[Guo Mahua]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221433592475.html