Install database in ubuntu (online)

1. Update the source list

Open the "Terminal Window", enter "sudo apt-get update" --> Enter --> "Enter the password of the root user" --> Enter, that's it. If you do not run this command and install mysql directly, there will be an error message that "there are several packages that cannot be downloaded, you can run apt-get update------", resulting in failure to install. 

2. Install mysql

Open the "Terminal Window", enter "sudo apt-get install mysql-server mysql-client" --> Enter --> Enter "y" --> Enter --> Enter in the "Package Settings Dialog" The password of the "root" user in mysql --> Enter --> Enter the password again --> Enter, the installation is complete.

(may be wrong mysql-client : depends on: mysql-client-5.5 but it will not be installed; mysql-server : depends on: mysql-server-5.5 but it will not be installed

Solution: Install first: sudo apt-get install mysql-client-core-5.5)

3. How to judge whether mysql is installed successfully

Open the "Terminal Window", enter "sudo service mysql restart" --> Enter --> If mysql starts successfully, it means mysql installation is successful if it is in the running state.

4. Let apache support mysql

Open the "Terminal Window", enter "sudo apt-get install libapache2-mod-auth-mysql"-->Enter-->Installation is successful, after installing this module, apache can support mysql.

(Let php support mysql to open the "terminal window", enter "sudo apt-get install php5-mysql" --> Enter --> successful installation, after installing this module, php can support mysql)

5. Login to mysql

Open the "Terminal Window", enter "mysql -u root -p" --> Enter --> Enter the password of the "root" user in mysql --> Enter --> Login successful.

After completing the installation of msql to ubuntu, it can only be used locally and cannot be connected through the external network (host/ip is named localhost). At this time, you need to modify the host/ip to the IP of the external network

1. Enter msql cd msql

2. Display detailed information (ls) or sudo vi my.cnf, find bind-address = localhost and comment it out (that is, add # before the line), and then press esc to exit

3. Restart the mysql service (sudo service mysql restart) and enter mysql (mysql -u root -p)

4. Query all users, host name select user, host from users

5. Modify root's host name/Ip: update user set host='%' where user='root';

6. Submit: flush privileges;

7. Restart the service and connect

Guess you like

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