MySQL installation and basic configuration in UbuntuLinux9.04

Source: Internet
Author: User
Tags mysql commands
The first time I installed MySQL on UbuntuLinux9.04 today, I have not installed MySQL before. So I have made some configuration by referring to some network articles, the following describes the entire process of installation. Installation and basic configuration. I install apt-get directly. This is also the installation method I have selected. My installation method is as follows: 1. sudoapt-getinstallmysql-server -- install the mysql server. I am prompted to set the root password when installing it on mysql 9.04. If

This is the first time I have installed MySQL on Ubuntu Linux 9.04. I have not installed MySQL before. So I have made some configurations by referring to some network articles. The following is the entire installation process.

I. Installation and basic usage Configuration
I directly use apt-get for installation. This is also the installation method I have selected. My installation method is as follows:
1. sudo apt-get install mysql-server -- install mysql server. When I install sudo apt-get on mysql 9.04, I am prompted to set the root password. If not, I can change the settings after installation, the default path after installation is/etc/init. d/mysql
2. sudo apt-get install mysql-client -- install the mysql client to perform CRUD operations on mysql. However, when the server is installed on mysql 9.04, you do not need to install the client, if not, install
Once the installation is complete, the MySql server should be automatically started. You can enter a command on the terminal to check whether the server is started:
Chentao @ amber-chentao :~ $ Sudo netstat-tap | grep mysql
When you execute this command, you can see the following information:
Tcp 0 0 localhost: mysql *: * LISTEN 8368/mysqld
Congratulations, this indicates that the mysql service has been started and installed successfully. If it cannot be started, run the following command to restart it:
Sudo/etc/init. d/mysql restart -- restart

After confirming that mysql is started, we need to log on to mysql. At this time, you can enter
Chentao @ amber-chentao :~ $ Mysql-uroot-p -- prompt to Enter the root password after executing Enter
Enter password:
After the password is entered, you can perform database operations.
If you want to set the mysql root Password, run the following command:
Chentao @ amber-chentao :~ $ Sudo mysqladmin-u root-oldpassword password newpassword

There are two other ways to change the password after entering the mysql terminal, that is, after entering mysql, execute the following command to change the current user password
1. mysql> set password for root = password ("root ");
2. mysql> grant all privileges on *. * to root @ localhost identified by "123456 ";

After all these settings are complete, we can create a new database and add a user to manage the CRUD operations of the database.
-- Create a database named test
Mysql> create database test;
-- Create a user named test_root who has the CRUD permission on the database test and can be used to manage the database in the future without the need for the Super User root.
Mysql> grant all privileges on test. * to test_root @ localhost identified by "654321"
-- We can see that the above configuration is too limited. The test_root user can only manage the test database. Sometimes we don't want to limit it to only one database, to grant CRUD permissions to all databases, run the following command:
Mysql> grant all privileges on *. * to test_root @ localhost identified by "654321 ";
Alternatively, you can change all privileges to insert, update, delete, create, select. The two methods are the same.

One bad thing about mysql is that after installation, only local access is allowed. remote access to the host is not allowed. If you want to set a user to access the host through a remote host, at this time, you need to set the mysql configuration, and the body needs to do two things, as follows:
1. mysql> grant all privileges on test_root @ "%" identified by "654321"
2. chentao @ amber-chentao :~ $ Sudo gedit/etc/mysql/my. cnf
Here, I used gedit text editing to open it. Of course, you can also use vi or vim to edit it. In this file, locate bind-address = 127.0.0.1, change it to bind-address = your local network IP address
In this way, you can allow your mysql to be accessed by other machines.
The basic configuration of your mysql service is completed. Below are some common mysql commands found on the network, which are attached for your convenience.

/Etc/init. d/mysql start -- start mysql
/Etc/init. d/mysql restart -- restart mysql
/Etc/init. d/mysql shutdown -- disable mysql Command
/Etc/init. d/mysql stop -- stop mysql Service
Chentao @ amber-chentao :~ $ Mysql-uroot-p -- log on to the mysql server, which describes

The following are some common mysql internal operation prompts.
Show databases; -- display the list of all databases
Use test; -- open the library
Show tables; -- view all data tables in the database
Describe tableName; -- query the table structure
Create table Name (field setting table); -- create table
Create database name; -- create a database
Drop database name; -- delete database
Drop table tablename -- delete table structure
Delete from table name; -- delete table data
Select * from table name; -- Query all data in the specified table

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.