【前言】
第一次在Ubuntu上面搭建JDK1.7 + Tomcat + MysqL,部署项目时候出现了各种问题,其中一个就是Ubuntu默认安装的MysqL是5.5,版本比较低,不支持datetime和CURRENT_TIMESTAMP,折腾了很久,最终安装这个文章安装上了MysqL。遇到的问题稍后整理。
转载自:http://blog.csdn.net/q894523017/article/details/50705392
1、安装 MysqL
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libaio1
--不要使用下面语句装
sudo groupadd MysqL
cd /usr/local/src
sudo wget MysqL-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
sudo chmod +x MysqL-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
tar -xf MysqL-server_5.7.10-1ubuntu14.04_amd64.deb-bundle.tar
ps:会解压出以下文件
libMysqLclient20_5.7.10-1ubuntu14.04_amd64.deb
libMysqLclient-dev_5.7.10-1ubuntu14.04_amd64.deb
libMysqLd-dev_5.7.10-1ubuntu14.04_amd64.deb
MysqL-community-client_5.7.10-1ubuntu14.04_amd64.deb
MysqL-community-server_5.7.10-1ubuntu14.04_amd64.deb
MysqL-community-source_5.7.10-1ubuntu14.04_amd64.deb
MysqL-client_5.7.10-1ubuntu14.04_amd64.deb
MysqL-community-test_5.7.10-1ubuntu14.04_amd64.deb
MysqL-common_5.7.10-1ubuntu14.04_amd64.deb
MysqL-server_5.7.10-1ubuntu14.04_amd64.deb
MysqL-community_5.7.10-1ubuntu14.04_amd64.changes
MysqL-testsuite_5.7.10-1ubuntu14.04_amd64.deb
更新设置到最新系统:
apt-get install libaio1
然后分别安装以下的包:
sudo dpkg -i MysqL-common_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg-preconfigure MysqL-community-server_5.7.10-1ubuntu14.04_amd64.deb
此步需要输入数据的root密码
sudo dpkg -i libMysqLclient20_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i libMysqLclient-dev_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i libMysqLd-dev_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i MysqL-client_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i MysqL-community-client_5.7.10-1ubuntu14.04_amd64.deb
sudo apt-get -f install
此步为了安装依赖包 libmecab2
sudo dpkg -i MysqL-community-server_5.7.10-1ubuntu14.04_amd64.deb
sudo dpkg -i MysqL-server_5.7.10-1ubuntu14.04_amd64.deb
这时数据安装完成,并自动启动
查看MysqL安装的路径和依赖:
whereis MysqL
MysqL: /usr/bin/MysqL /etc/MysqL /usr/lib/MysqL /usr/include/MysqL /usr/share/MysqL /usr/share/man/man1/MysqL.1.gz
这时你会发现 MysqL以服务形式自启动
2、开启远程访问访问
skip-network
现在则变成了:
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1
就是只监听本机地址。所以,如果要开放局域网内的访问,需要注释掉这一句,或者改成:
bind-address = 0.0.0.0
就行了
# vi /etc/MysqL/my.cnf
bind-address = 127.0.0.1 为 bind-address = 0.0.0.0
这样改完3306端口就开始监听了,但是MysqL的权限还没有打开ROOT远程登陆
MysqL默认是不允许远程连接的,因为有很大的安全隐患。
#MysqL -u root -proot
MysqL>update user set host = '%' where user = 'root';
MysqL>select host,user from user;
MysqL>FLUSH PRIVILEGES;
修改完这些就可以远程访问了。
启动:sudo /etc/init.d/MysqL start
停止:sudo /etc/init.d/MysqL stop
重启:sudo /etc/init.d/MysqL restart
原文链接:https://www.f2er.com/ubuntu/353040.html