Ubuntu 16 Mysql installation configuration

  Install Mysql

    apt-get update; 

    apt-get install mysql-server

   apt-get install mysql-client

  // During the installation process, you will be prompted to change the password or something

   >mysql -u root -p

   >

   >show databases; //View databases

   > use "base"; //use the database

   > show tables; //View tables

   > desc "table"; //View table structure

   > CREATE USER 'username'@'host' IDENTIFIED BY 'password';

  //Description: username - the username you will create, host - specify on which host the user can log in, if it is a local user, you can use localhost,

  //If you want the user to log in from any remote host, you can use the wildcard %. password - the user's login password, the password can be empty, if it is empty, the user can log in to the server without a password. 

   > Grant ALL ON *.* to 'username'@'%'

   > flush privileges;

     Modify the Mysql configuration file, installed version 5.7, the configuration file is located in /etc/mysql/mysql.conf.d/mysqld.cnf

  [mysqld_safe]
  socket = /var/run/mysqld/mysqld.sock
  nice = 0
  [client]
  default-character-set=utf8
  [mysql]
  default-character-set=utf8
  [mysqld]
  #
  # * Basic Settings

  Mainly to change the default character to utf-8

  

   Execute the .sql file in Mysql

  Execute this command, you will be prompted to enter the account name and password. After the verification is successful, the script filename.sql will be executed in the database dbname, and filename.sql refers to the path of the sql

  >mysql -u root -p dbname>filename.sql

    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325204563&siteId=291194637