Run the following command to install MySQL in Ubuntu: sudoapt-getinstallmysql-serverMySQL initial configuration and management start MySQLmysqlstart: mysqld is the mysql daemon to check whether mysql is started: ps-ef | Common commands in grepmysqldMySQL to connect to SQL: Install mysql in MySQL Ubuntu
Command: sudo apt-get install mysql-server
MySQL initial configuration and management
Common commands in MySQL
- Connection SQL: mysql-h host name-u user name-p User Password
- Show databases/tables;
- Create: create database/tables;
- Delete: drop database name; delete from tablesName where condition;
- Connect to the database: use databaseName;
- Query: select * from databaseName;
- Insert: insert into tableName values ();
- Add field: alter table name add field type others;
- Update: update tableName set field = new value where condition;
- Modify table Name: rename table original table name to new table name
How to view error logs
- System Error:/var/log/syslog
- Mysql log:/var/log/mysql
Errors and Solutions
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld. sock' (2)
Solution:
mysql server startps -ef | grep mysqlkill [the id]sudo /etc/init.d/mysql restart
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2
This article permanently updates the link address: Http://www.linuxidc.com/Linux/2016-04/129724.htm