linux怎么操作mysql命令行,安装Linux版MySql教程,命令行操作

2018更新

ubuntu最新安装可按照此步骤:

1.安装mysql

#命令1

sudo apt-get update

#命令2

sudo apt-get install mysql-server

输入Y确认,中间会弹出让输入root用户密码,输入一遍下一步再输入确认一遍;

2.配置mysql

sudo mysql_secure_installation

配置项较多,如下所示:

#1

VALIDATE PASSWORD PLUGIN can be used to test passwords...

Press y|Y for Yes, any other key for No: N (我的选项)

#2

Please set the password for root here...

New password: (输入密码)

Re-enter new password: (重复输入)

#3

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them...

Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项)

#4

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network...

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的选项)

#5

By default, MySQL comes with a database named 'test' that

anyone can access...

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项)

#6

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)

3.检查mysql服务状态

systemctl status mysql.service

看到active(running)字样证明启动正常

4.配置远程访问

先去 /etc/mysql/my.cnf 或者 /etc/mysql/mysql.conf.d/mysqld.cnf 找到如下配置项:

bind-address = 127.0.0.1

修改为:

bind-address = 0.0.0.0

然后进入mysql

mysql -u root -p password

password为安装步骤时你设置的root密码

grant all privileges on *.* to root@"%" identified by "password" with grant option;

password同上,然后依次执行如下命令:

flush privileges;

exit

/etc/init.d/mysql restart

结束,旧版 ubuntu 或 CentOS6 参考如下安装

————————————

安装

64位tar: http://dev.mysql.com/downloads/file/?id=459257

32位tar:http://dev.mysql.com/downloads/file/?id=459256

压缩包

64位tar.gz:http://dev.mysql.com/downloads/file/?id=459272

64位tar.gz:http://dev.mysql.com/downloads/file/?id=459273

-----------------------------

5.5.46

tar:http://dev.mysql.com/downloads/file/?id=459035

tar.gz:http://dev.mysql.com/downloads/file/?id=459051

1安装:rpm

l  步骤1:检查是否已经安装mysql,如果安装删除。

076c86fcdbda994a0bd6db792d620156.png

--nodeps表示:不验证套件档的相互关联性。

否则

3e69c2c5b00e34f40573261481534fd3.png

l  步骤二:上传“MySQL-5.5.46-1.linux2.6.x86_64.rpm-bundle.tar”,并解压

上传

94ea90c6d68b67b13868e143d755c302.png

解压

aee6d8406c02da208cc115755ccf8700.png

l  步骤三:安装service和client

89ff2170286a6495b1bcdb1b0fc14295.png

9b55ea1b764a7994e2635a45fc9d2a6f.png

l  步骤四:启动程序

d9711559562073f145c81c2d06ebb5d4.png

l  步骤五:登录

bda375ee745ef7d76ad479611648efed.png

2安装:yum

l  步骤一:检查是否有低版本的mysql,如果有卸载

0a9b84ce285bb4a6f1bd354866377378.png

f8166a817154cd2a5ad9304d7ca93662.png

l  步骤二:上传“MySQL-5.5.46-1.linux2.6.x86_64.rpm-bundle.tar”,并解压。删除其他,只需要service和client

a784fa07dad2b9e5ff36de9fc4ea21e8.png

l  步骤三:安装

c7e99a3444c5029ba0fb4e275e222b47.png

6b5af8020fa495c182b704922da3b3b5.png

l  步骤四:启动

16e0992d576e031d6a05e0462910da90.png

l  步骤五:登录

ebddf6a8fbb4ef1e47a165ee96b157a0.png

3版本(之前)

l  步骤一:查询是否已经安装mysql

070bcdf8d774d0975a786cfb24cc1a21.png

l  步骤二:如果已经安装卸载

943ed6b527f119b4455e0e7066f4b6e5.png

l  步骤三:上传MySQL-5.6.25-1.el6.x86_64.rpm-bundle.tar

3b57a86824caeca5890d614d591f6dc5.png

l  步骤四:解压

35c98f209a3711bd609e7d016d4161f5.png

49620dedabc39de1376524aeb768e72c.png

l  步骤五: 安装

ad6cd0547f414f49e2db0b89bfb682da.png

10995c2b3ac9693ce941ba9c9c8985bf.png

c689c1e55c1bca1ae82355c7a2cdf6c5.png

l  步骤六:启动服务

l  重写修改密码

61d7f7b5471084c5b1879807d73e31e0.png

5adc2d9ccb72ada72dd412726e2e30bc.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值