Getting started-install MySQL databases and related operations under Ubuntu

Source: Internet
Author: User

1. Install MySQL

Sudo apt-Get install mysql-Server
Sudo apt-Get install mysql-Client
Sudo apt-Get install mysql-Admin
This should be very simple, and I don't think there is much problem with the installation, so I will not talk about it much. Let's talk about the configuration below.
You can also use the Ubuntu management tool to install the tool. When using this tool, I am prompted to enter the Database Password.

Ii. MySQL related operations and configurations.

Root @ Ubuntu:/home/smallstar #/etc/init. d/MySQL
Usage:/etc/init. d/MySQL START | stop | restart | reload | force-Reload | status

/Etc/MySQL/main configuration file location my. CNF
Root @ Ubuntu:/home/smallstar # gedit/etc/MySQL/My. CNF

Earlier versions

> Skip-networking => # Skip-networking

New Version

> Bind-address = 127.0.0.1 => # bind-address = IP address of your machine

This allows other machines to access MySQL.

/Var/lib/MySQL/stores the database table folder. Here, MySQL is equivalent to the date folder of MySQL in windows.
Debian-5.0.flag ib_logfile0 MySQL openmeetings
Ibdata1 ib_logfile1 mysql_upgrade_info xoops

4. log on to the MySQL database, create a database, and modify the encoding.
Logon: mysql-u root-P
Create Database: Create Database openmeetings;

> Show variables like 'character % '; # display the code
+ -------------------------- + ---------------------------- +
| Variable_name | value |
+ -------------------------- + ---------------------------- +
| Character_set_client | Latin1 |
| Character_set_connection | Latin1 |
| Character_set_database | Latin1 |
| Character_set_filesystem | binary |
| Character_set_results | Latin1 |
| Character_set_server | Latin1 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/MySQL/charsets/|
+ -------------------------- + ---------------------------- +

In some cases, we need to modify the encoding of the default MySQL database to ensure that some migrated programs can be properly displayed. edit my. modify the CNF file encoding. For Windows, you can directly use MySQL server instance config Wizard to set

Modify one of the three my. CNF files in Linux:/etc/MySQL/My. CNF

Find the client configuration [client] and add it below
Default-character-set = utf8 default Character Set: utf8
Add in [mysqld]
Default-character-set = utf8 default Character Set: utf8
Init_connect = 'set names utf8' (utf8 encoding is used to set the connection to the MySQL database to run utf8)

After modification, restart MySQL and query show variables like 'character % ';
+ -------------------------- + ---------------------------- +
| Variable_name | value |
+ -------------------------- + ---------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | utf8 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | utf8 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/MySQL/charsets/|
+ -------------------------- + ---------------------------- +

5. Basic MySQL operations
1. Connect to the MySQL database:
Format: mysql-H host address-u user name-P User Password
For example, connecting to a local MySQL Server
Mysql-u root-P press enter, and a prompt box appears, asking you to enter the password
Connect to a remote MySQL Server
Mysql-h10.1.17.73-uroot-plogin
2. Exit MYSQL:
Command: Exit
3. MySQL password,
(Note: the root user of the MySQL database that has just been installed does not have a password .)
Format: mysqladmin-u username-P old Password New Password
For example, add a password to the root user (when installation is complete)
Mysqladmin-uroot-password login
Change Root Password
Mysqladmin-uroot-plogin password welcome
4. The following are some of the most common database operation commands:
Show databases // display the Database Name
Show tables; // show table
Use databases_name; show tables; // display the table structure in the database
Describe table_name; // display the data table structure
Create Database database_name; // create a database
Use database_name; Create Table table_name (Field List); // create a table
Drop database database_name; // delete a database
Drop table table_name; // delete a table
Delete from table_name; // clear the table
5. convert text data to the database
(Note: Text data fields are separated by tabs, and null values are replaced by N .)
Data Loading command:
Load da

Ta local infile "FILENAME" into Table table_name
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.