美文网首页
ubuntu 快速安装mySql

ubuntu 快速安装mySql

作者: lipeiyan | 来源:发表于2016-10-13 15:29 被阅读22次

    Step 1: Update your system by typing the following commands:

    sudo apt update
    sudo apt upgrade
    

    Step 2: Install mysql version 5.7 on Ubuntu 16.04

    sudo apt install mysql-server mysql-client
    

    Step 3: Run mysql_secure_installation to secure your installation

    sudo mysql_secure_installation
    

    Step 4: How do I use MySQL server?

    mysql -u root -p
    

    Step 5: How do I create a new MySQL server database and user account?

    mysql> create database wpblogdb;
    mysql> grant all on wpblogdb.* to 'vivek' identified by 'fooBarPwd8-4_2';**
    mysql> quit;
    

    Now, try to log in as vivek user, enter:

    mysql -u USERNAME -p DB-NAME-HERE
    mysql -u vivek -p wpblogdb
    

    How do I start MySQL server?

    sudo systemctl start mysql
    

    OR

    sudo systemctl start mysql.service
    

    How do I restart MySQL server?

    sudo systemctl restart mysql
    

    OR

    sudo systemctl restart mysql.service
    

    How do I find out if MySQL running/active?

    sudo systemctl status mysql.service
    

    How do I reset the mysql root account password?

    sudo dpkg-reconfigure mysql-server-5.7
    

    A note about MySQL server configuration
    You may edit the /etc/mysql/my.cnf
    file to configure the basic settings such as TCP/IP port, IP address binding, and other options. However, The MySQL database server configuration file on the Ubuntu 16.04 LTS is located at/etc/mysql/mysql.conf.d/mysqld.cnf
    and one can edit using a text editor such as vi or nano:

    sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
    

    OR

    sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
    

    After making a change to /etc/mysql/mysql.conf.d/mysqld.cnf
    the MySQL server will need to be restarted:

    sudo systemctl restart mysql.service
    

    And, there you have it, the MySQL database version 5.7 installed and working correctly on the latest version of Ubuntu Linux 16.04 LTS. For more information see MySQL 5.7 Reference Manual.

    查看原文

    相关文章

      网友评论

          本文标题:ubuntu 快速安装mySql

          本文链接:https://www.haomeiwen.com/subject/qzbwyttx.html