1.首先删除mysql:
sudo apt-get remove mysql-*
dpkg -l |grep ^rc|awk ‘{print $2}’ |sudo xargs dpkg -P
2.然后安装mysql.
可以直接默认安装:
sudo apt-get install mysql-client mysql-server
因为Ubuntu是16.04的,所以会默认安装5.7版本。
如果要安装5.6(因为5.7版本据说经常出错),按以下步骤:
复制代码
sudo add-apt-repository ‘deb http://archive.ubuntu.com/ubuntu trusty universe’ //增加旧的repo
sudo apt-get update //更新源
sudo apt-cache search mysql | grep 5.6 //查看软件源里时候有mysql 5.6 可供安装
//查看结果
percona-server-server-5.6 - Percona Server database server binaries
percona-server-test-5.6 - Percona Server database test suite
percona-xtradb-cluster-server-5.6 - Percona XtraDB Cluster database server binaries
mysql-client-5.6 - MySQL database client binaries
mysql-client-core-5.6 - MySQL database core client binaries
mysql-common-5.6 - MySQL 5.6 specific common files, e.g. /etc/mysql/conf.d/my-5.6.cnf
mysql-server-5.6 - MySQL database server binaries and system database setup
mysql-server-core-5.6 - MySQL database server binaries
mysql-source-5.6 - MySQL source
mysql-testsuite-5.6 - MySQL 5.6 testsuite
sudo apt-get install mysql-server-5.6 mysql-client-5.6 //安装
复制代码
安装完成后查看mysql状态:
sudo service mysql status
一般安装完成之后都是会自动运行的。
如果没有运行你可以
sudo service mysql start
运行它。
3.安装MySQL可视化操作工具 MySQL Workbench
sudo apt install mysql-workbench