Mysql learning-Basic use

Source: Internet
Author: User
Mysql learning-once the installation is complete, the MySQL server should be started automatically. Sudostartmysql # Start sudostopmysql manually # Stop it manually. After you modify the configuration file, restart mysqld to make the changes take effect. To check whether the mysqld process is enabled, run the following command: pg

Mysql learning-once the installation is complete, the MySQL server should be started automatically. Sudo start mysql # start sudo stop mysql manually # stop it manually. After you modify the configuration file, restart mysqld to make the changes take effect. To check whether the mysqld process is enabled, run the following command: pg

Mysql learning-basic usage

Once the installation is complete, the MySQL server should be started automatically.

Sudo start mysql # start it manually
Sudo stop mysql # manually stop

After you modify the configuration file, you need to restart mysqld to make these changes take effect.

To check whether the mysqld process is enabled, run the following command:

pgrep mysqld

If the process is enabled, the command returns the id of the process.

MySQL configuration file:/etc/mysql/my. cnf, which specifies the data file storage path

datadir         = /var/lib/mysql

If you create a database named test, the data in the database will be stored in the/var/lib/mysql/test directory.

Go to MySQL

mysql -u root -p 

(Enter the mysql root Password)

qii@ubuntu:~$ mysql -u root -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 37Server version: 5.1.41-3ubuntu12.3 (Ubuntu)Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 

Modify the MySQL administrator password:

sudo mysqladmin -u root password newpassword;

View the databases owned by the current user:

Mysql> show databases
->;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
+ -------------------- +
3 rows in set (0.19 sec)

View the databases available to the current user:

Mysql> show databases
->;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
+ -------------------- +
3 rows in set (0.19 sec)

Mysql> show tables
->;
ERROR 1046 (3D000): No database selected
Mysql> select table_name from user_tables;
ERROR 1046 (3D000): No database selected
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
+ -------------------- +
3 rows in set (0.00 sec)

Select the current database:

Mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-

Database changed

View tables in the current database:
Mysql> show tables
->;
+ --------------------------- +
| Tables_in_mysql |
+ --------------------------- +
| Columns_priv |
| Db |
| Event |
| Func |
| General_log |
| Help_category |
| Help_keyword |
| Help_relation |
| Help_topic |
| Host |
| Ndb_binlog_index |
| Plugin |
| Proc |
| Procs_priv |
| Proxies_priv |
| Servers |
| Slow_log |
| Tables_priv |
| Time_zone |
| Time_zone_leap_second |
| Time_zone_name |
| Time_zone_transition |
| Time_zone_transition_type |
| User |
+ --------------------------- +
24 rows in set (0.00 sec)

View the details of a table:

Mysql> describe servers;
+ ------------- + ---------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ ------------- + ---------- + ------ + ----- + --------- + ------- +
| Server_name | char (64) | NO | PRI |
| Host | char (64) | NO |
| Db | char (64) | NO |
| Username | char (64) | NO |
| Password | char (64) | NO |
| Port | int (4) | NO | 0 |
| Socket | char (64) | NO |
| Wrapper | char (64) | NO |
| Owner | char (64) | NO |
+ ------------- + ---------- + ------ + ----- + --------- + ------- +
9 rows in set (0.04 sec)

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.