如何在ubuntu下安装mysql客户端

如何在ubuntu下安装mysql客户端,第1张

打开终端,进行如下 *** 作: 1. sudo apt-get install mysql-server 2. apt-get isntall mysql-client 3. sudo apt-get install libmysqlclient-dev 安装过程中会提示设置密码什么的,注意设置了不要忘了,安装完成之后可以使用如下命令来检查是否安装成功: sudo netstat -tap | grep mysql 通过上述命令检查之后,如果看到有mysql 的socket处于 listen 状态则表示安装成功。

在ubuntu中,我们常用apt-get命令插件,其实,它也一直在更新相应的资源库,到目前为止,

apt-get资源库中 mysql 的最新版本为:mysql-5.7.29

因此,我们可以直接通过最新版本apt-get命令安装mysql57即可,避免手动安装的许多麻烦;

本文将带你一起走一遍原原本本的安装流程,如果你,正准备在ubuntu系统上安装mysql57,那么恭喜你,这篇文章必然会帮到你。如果遇到什么麻烦,尽快在下方留言,我,会及时给老兄诊断下问题所在。

1.查看mysql有没有已安装的依赖包

复制

先卸载mysql-common

复制

再执行:

复制

然后继续用 dpkg --list|grep mysql 查看,还剩什么就卸载什么;

二、安装mysql

复制

复制

Ubuntu16 - Ubuntu18安装mysql5.7未提示输入密码,mysql默认密码为空;直接登录即可;

如果使用mysql -uroot -p 命令连接mysql时,报错

复制

1.此时修改root的默认密码即可: 1.进入到/etc/mysql/ 目录下,查看debian.cnf文件

2.找到用户名,密码 ,使用此账号登录mysql 用户名:debian-sys-maint 密码:UsIgysQBZbL6X4qW 登录: mysql -udebian-sys-maint -pUsIgysQBZbL6X4qW

3.修改root用户的的密码 这里是关键点,由于mysql5.7没有password字段,密码存储在authentication_string字段中,password()方法还能用在mysql中执行下面语句修改密码:

复制

4.修改完密码,需要重启mysql;再次登录就可以了;

进入mysql命令行输入:show variables like 'character%'

我们需要把database和server调成utf8即可;

首先我们找到mysqld.cnf文件:find / -name mysqld.cnf

修改mysqld.cnf内容:在相应标签下添加即可(如下图), 没有[mysql]标签就加上

复制

保存后重启mysql;service mysql restart重启后再次登陆mysql命令行

输入show variables like 'character%'

在Linux Ubuntu中安装MySQL数据库

#安装MySQL服务器

~ sudo apt-get install mysql-server

安装过程会d出提示框,输入root用户的密码,我在这里设置密码为mysql。

安装完成后,MySQL服务器会自动启动,我们检查MySQL服务器程序

# 检查MySQL服务器系统进程

~ ps -aux|grep mysql

mysql 3205 2.0 0.5 549896 44092 ?Ssl 20:10 0:00 /usr/sbin/mysqld

conan 3360 0.0 0.0 11064 928 pts/0S+ 20:10 0:00 grep --color=auto mysql

# 检查MySQL服务器占用端口

~ netstat -nlt|grep 3306

tcp0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

# 通过启动命令检查MySQL服务器状态

~ sudo /etc/init.d/mysql status

Rather than invoking init scripts through /etc/init.d, use the service(8)

utility, e.g. service mysql status

Since the script you are attempting to invoke has been converted to an

Upstart job, you may also use the status(8) utility, e.g. status mysql

mysql start/running, process 3205

# 通过系统服务命令检查MySQL服务器状态

~ service mysql status

mysql start/running, process 3205

3. 通过命令行客户端访问MySQL

安装MySQL服务器,会自动地一起安装MySQL命令行客户端程序。

在本机输入mysql命令就可以启动,客户端程序访问MySQL服务器。

~ mysql

Welcome to the MySQL monitor. Commands end with or \g.

Your MySQL connection id is 42

Server version: 5.5.35-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

使用户名和密码,登陆服务器

~ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with or \g.

Your MySQL connection id is 37

Server version: 5.5.35-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5903118.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-07
下一篇 2023-03-07

发表评论

登录后才能评论

评论列表(0条)

保存