Ubuntu 13.04 install MySQL database tutorial

Source: Internet
Author: User
Tags bind reserved create database mysql database

  Ubuntu is a popular Linux operating system, based on the Debian distribution and GNOME desktop environment, and compared to other Linux distributions, Ubuntu is very easy-to-use, and Windows compatibility is very good for Windows user migration, Pre-installed a large number of commonly used software, Chinese version of the function is also more complete, support pinyin input method, pre-installed with Firefox, Open Office, multimedia playback, image processing and most commonly used software, usually automatically installed network card, sound card and other equipment drivers.

  Install MySQL   can use Ubuntu Software Center or APT command to install MySQL on Ubuntu, both of which are very convenient.   1. Using Ubuntu Software Center: Open Ubuntu Software Center, search the box in the upper right-hand corner for MySQL, then select MySQL Server, click Install.   2. Use apt: Open terminal to perform "sudo apt-get install Mysql-server" can.   MySQL initial configuration   MySQL after the installation can be directly logged on using the root account, and the account default is no password. Note that the root role here refers to your Ubuntu root role, and if you are currently using a system account that is not root, you do not have to switch to the system root account, and you can use the "-u" parameter to specify the login account when you log in to MySQL. such as:   $ mysql-u root   mysql> 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 | &nbSp | 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 can log in as root without entering a password and Permission to view all information. If you are logged in to MySQL with a non-root role, you will only have partial database operation permissions.   $ mysql   mysql> show databases;   +--------------------+   | Database |   +--------------------+   | Information_schema |   | Test |   +--------------------+   2 rows in Set (0.00 sec)   mysql> use MySQL   ERROR 1044 (42000) : Access denied for user ' @ ' localhost ' to database ' MySQL '   so the first thing that MySQL completes after installation is to set a password for the root user, otherwise the database will be unsafe.   Mysql> GRANT all privileges on *.* to root@localhost identified by "";   Replace the above command with the password you want to set, which means that the root user who logged in with the password on the local computer (localhost) is given permission to operate the database. After setting the password, if you are logged in as root, you will need to enter a password, such as:   $ mysql-u root   ERROR 1045 (28000): Access denied for user ' root ' @ ' Localho St ' (using Password:no)   $ Mysql-u root-p   Enter Password:   Welcome to the MySQL Monitor. Commands End With; or G.   Your MySQL Connection ID is +   Server version:5.5.34-0ubuntu0.13.10.1 (Ubuntu)   Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.   Oracle is a registered trademark to Oracle Corporation and/or its   affiliates. Names may trademarks of their respective   owners.   Type ' help; ' or ' H ' to help. Type ' C ' to clear the current input statement.   mysql>   Set up database independent users   because the root user has all the operational rights of the database, it is not easy to provide to others to use. In a MySQL instance, you can create multiple databases, which may belong to different projects, and each database has an operational role. This can be accessed by the user specified for the different database.   First use the root role to create a database   mysql> CREATE DATABASE Db_web_monitor   then grant this database to a user named Xavier using   my Sql> GRANT all privileges on the db_web_monitor.* to Xavier@localhost identified by "Xavier";   So you can use the Xavier user, the password for Xavier in the local login MySQL operation Db_web_monitor database.   $ mysql-u XAvier   ERROR 1045 (28000): Access denied for user ' Xavier ' @ ' localhost ' (using Password:no)   $ mysql-u xa Vier-p   Enter Password:   Welcome to the MySQL Monitor. Commands End With; or G.   Your MySQL Connection ID is +   Server version:5.5.34-0ubuntu0.13.10.1 (Ubuntu)   Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.   Oracle is a registered trademark to Oracle Corporation and/or its   affiliates. Names may trademarks of their respective   owners.   Type ' help; ' or ' H ' to 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>   Open Telnet permission   1. First, modify the MySQL configuration file to allow remote logins to be monitored.    $ sudo vi/etc/mysql/my.cnf   find bind-address in line   Instead of skip-networking of the ' default is ' now to Lis Ten only on   # localhost which are more compatible and are not less secure.   bind-address = 127.0.0.1   Change bind-address value to native IP.   Note that if it is an older version of MySQL, it should be skip-networking, just annotate it.   2. Grant a user Telnet permission.   Mysql>grant all privileges on db_web_monitor.* to xavier@ "%" identified by "Xavier";   So, Xavier users can be in any host through IP access to the native MySQL, db_web_monitor database operation.  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.