这篇文章将为大家详细讲解有关Linux中MySQL怎么用,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1.show databases;2.use mysql转换database3.show tables 显示数据库里的表4.select user,host,password from user查询我的数据库mysql的user,host,password5.给账号设置密码mysql> update user set password=password('123456') where user='root';6.清除空用户delete From user where user='' ;7.查看剩余用户命令与上文相同的查询用户命令 8.刷新权限(重点)命令flush privileges;每次操作结束后都要刷新权限!!9.通过用户进入数据库mysql -u root -p123456; (-p后全是密码)10.编辑.bash_profile文件(此步骤是为了可以让我们使用which mysql直接找到mysql文件在哪)vi 。bash_profile修改为# .bash_profile # Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/bin 1,1 Top# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfi# User specific environment and startup programsexport MYSQL_BASE=/usr/local/mysqlexport PATH=${MYSQL_BASE}/bin:$PATHPS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1得到结果11.创建一个新的数据库并且设定可以进入他的机器11.1 create database ruozedb;创建数据库ruozedb11.2grant all privileges on ruozedb.* to ruoze@'192.168.137.252' identified by '123456'设定可以进入数据库ruozedb的用户只有IP为192.168.137.252的用户名叫做ruoze且密码为123456(如果把IP地址改为%则表示任意ID都可以用ruoze用户进入)11.3flush privileges;权限刷新实践如图:12.连接Dbeaver
关于“Linux中MySQL怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。