Ubuntu下安裝配置MySQL

來源:互聯網
上載者:User

Ubuntu下安裝配置MySQL
Ubuntu下安裝MySQL

命令: sudo apt-get install mysql-server

MySQL初始配置及管理
  • 啟動MySQL

    mysql start : mysqld是mysql的守護進程

  • 檢查mysql是否啟動:

    ps -ef | grep mysqld

MySQL下的常用命令
  • 串連SQL: mysql -h 主機名稱 -u 使用者名稱 -p 使用者密碼
  • 顯示: show databases/tables;
  • 建立: create database/tables;
  • 刪除:drop database name;delete from tablesName where 條件;
  • 串連資料庫:use databaseName;
  • 查詢:select * from databaseName;
  • 插入:insert into tableName values( );
  • 增加欄位: alter table 表名 add 欄位 類型 其他;
  • 更新:update tableName set 欄位 = 新值 where 條件;
  • 修改表名 : rename table 原表名 to 新表名
如何查看錯誤log
  • 系統錯誤: /var/log/syslog
  • mysql日誌:/var/log/mysql
錯誤及解決的方法

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

解決的方法:

mysql server startps -ef | grep mysqlkill [the id]sudo /etc/init.d/mysql restart

相關文章

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.