Install and configure MySQL in Ubuntu
Install MySQL in 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/mysqld.sock' (2)
Solution:
mysql server startps -ef | grep mysqlkill [the id]sudo /etc/init.d/mysql restart