Ubuntu is a popular Linux operating system. based on the Debian release and GNOME desktop environment, Ubuntu is very easy to use and has good compatibility with Windows compared with other Linux releases.
Ubuntu is a popular Linux operating system. based on the Debian release and GNOME desktop environments, Ubuntu is very easy to use and compatible with Windows compared with other Linux releases, it is very suitable for migration of Windows users. it comes with a large number of frequently-used software pre-installed and a full range of functions. it supports pinyin input methods, and is pre-installed with most frequently-used software such as firefox, Open Office, multimedia playback, and image processing, generally, the driver of the NIC, audio card, and other devices is automatically installed.
Install MySQL
On Ubuntu, you can use the Ubuntu Software Center or apt command to install MySQL. both methods are very convenient.
1. use Ubuntu Software Center: open Ubuntu Software Center, query mysql in the search box in the upper right corner, select MySQL Server, and click install.
2. use apt: open the terminal and run "sudo apt-get install mysql-server.
MySQL initial configuration
After installing MySQL, you can log on directly using the root account without a password by default. Note that the root role here refers to your Ubuntu root role. if your current system account is not root, you do not have to switch to the system root account, you can use the "-u" parameter to specify the logon account when logging on to MySQL. For example:
$ mysql -u rootmysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test |+--------------------+4 rows in set (0.00 sec)mysql> select Host, User from user;+-----------+------------------+| Host | User |+-----------+------------------+| 127.0.0.1 | root || ::1 | root || iUbuntu | || iUbuntu | root || localhost | || localhost | debian-sys-maint || localhost | root |+-----------+------------------+7 rows in set (0.00 sec)
Because the root account does not have a password by default, you do not need to enter the password to log on to and view all the information. If you use a non-root role to log on to MySQL, you only have some database operation permissions.
$ mysqlmysql> show databases;+--------------------+| Database |+--------------------+| information_schema || test |+--------------------+2 rows in set (0.00 sec)mysql> use mysqlERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
Therefore, the first thing after MySQL installation is to set a password for the root user. Otherwise, the database will be unsecure.
mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "
";
Replace Replace it with the password you want to set. the above Command means to use The root user who logs on with the password gives all database operation permissions. After setting the password, if you log on as the root user, you need to enter the password, for example:
$ mysql -u rootERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)$ mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 75Server version: 5.5.34-0ubuntu0.13.10.1 (Ubuntu)Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
Create independent database users
Because the root user has all the database operation permissions, it cannot be provided to others easily. You can create multiple databases in a MySQL instance. These databases may belong to different projects and have different operation roles for each database. This can be accessed by specified users in different databases.
First, use the root role to create a database mysql> create database db_web_monitor, and then assign this database to a user named xavier to use mysql> grant all privileges on db_web_monitor. * TO xavier @ localhost identified by "xavier ";
In this way, you can use the xavier user and use the password xavier to log on to MySQL to operate the db_web_monitor database.
$ mysql -u xavierERROR 1045 (28000): Access denied for user 'xavier'@'localhost' (using password: NO)$ mysql -u xavier -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 77Server version: 5.5.34-0ubuntu0.13.10.1 (Ubuntu)Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || db_web_monitor || test |+--------------------+3 rows in set (0.00 sec)mysql>
Enable remote logon
1. first, modify the MySQL configuration file to allow remote logon listening.
$ Sudo vi/etc/mysql/my. cnf finds the bind-address row 45 # Instead of skip-networking the default is now to listen only on 46 # localhost which is more compatible and is not less secure. 47 bind-address = 127.0.0.1 modify the bind-address value to the local IP address. Note that for MySQL of earlier versions, it should be skip-networking. just comment it out.
2. Grant the remote logon permission to the user.
mysql>GRANT ALL PRIVILEGES ON db_web_monitor.* TO xavier@"%" IDENTIFIED BY "xavier";
In this way, xavier users can access the local MySQL database through IP address on any host and operate the db_web_monitor database.