当前位置:   article > 正文

Ubuntu安装Mysql数据库_ubuntu查看数据库

ubuntu查看数据库

1、首先查看Ubuntu中是否安装过mysql,使用如下命令。

dpkg -l | grep mysql

若没有安装则不会出现任何提示,如下图是安装过的。

2、安装mysql-server

sudo apt install mysql-server

3、 再次验证是否安装mysql,上面有截图

dpkg -l | grep mysql

root@Eth002:/home/caojun/FISCO/WeBASE-Node-Manager# dpkg -l | grep mysql
ii  mysql-client-5.7                       5.7.40-0ubuntu0.18.04.1                   amd64        MySQL database client binaries
ii  mysql-client-core-5.7                  5.7.40-0ubuntu0.18.04.1                   amd64        MySQL database core client binaries
ii  mysql-common                           5.8+1.0.4                                 all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                           5.7.40-0ubuntu0.18.04.1                   all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.7                       5.7.40-0ubuntu0.18.04.1                   amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7                  5.7.40-0ubuntu0.18.04.1                   amd64        MySQL database server binaries

 该命令也可以进行验证

netstat -tap | grep mysql

 在控制台输入下面的命令进行登录

mysql -u root -p

 查看数据库

show databases;

创建数据库,直接复制即可,创建一个node的数据库。

CREATE DATABASE IF NOT EXISTS node DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

 

 exit退出控制台

 初始化mysql数据库,退出mysql控制台后使用如下命令

mysql_secure_installation

 下面会出现一些选项配置,可以按照自己需要进行配置

1、首先是安装验证插件,选择N

 2、设置root的密码,重复输入两次

 3、删除匿名账户

4、删除默认的测试数据库

5、刷新授权的

 6、查看mysql运行状态

systemctl status mysq

 7、配置mysql远程访问机制,注销这一行(43行),保存退出

vim /etc/mysql/mysql.conf.d/mysqld.cnf

 在[mysqld]里面添加 skip-grant-tables

 8、进行mysql控制台进行刷新权限,如下命令按照顺序执行即可

mysql -u root -p
grant all on *.* to root@'%' identified by '123456' with grant option;
flush privileges;
exit
systemctl restart mysql
systemctl status mysql

 9、远程连接,在另外一台电脑上面进行远程连接测试,输入mysql数据库电脑的ip及数据库3306端口、用户名、密码

 这里就是新建的数据库

附上:

  1. root@Eth002:/home/caojun/FISCO/WeBASE-Node-Manager/dist/script# mysql_secure_installation
  2. Securing the MySQL server deployment.
  3. Connecting to MySQL using a blank password.
  4. VALIDATE PASSWORD PLUGIN can be used to test passwords
  5. and improve security. It checks the strength of password
  6. and allows the users to set only those passwords which are
  7. secure enough. Would you like to setup VALIDATE PASSWORD plugin?
  8. Press y|Y for Yes, any other key for No: N
  9. Please set the password for root here.
  10. New password:
  11. Re-enter new password:
  12. By default, a MySQL installation has an anonymous user,
  13. allowing anyone to log into MySQL without having to have
  14. a user account created for them. This is intended only for
  15. testing, and to make the installation go a bit smoother.
  16. You should remove them before moving into a production
  17. environment.
  18. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
  19. Success.
  20. Normally, root should only be allowed to connect from
  21. 'localhost'. This ensures that someone cannot guess at
  22. the root password from the network.
  23. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
  24. ... skipping.
  25. By default, MySQL comes with a database named 'test' that
  26. anyone can access. This is also intended only for testing,
  27. and should be removed before moving into a production
  28. environment.
  29. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
  30. ... skipping.
  31. Reloading the privilege tables will ensure that all changes
  32. made so far will take effect immediately.
  33. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
  34. Success.
  35. All done!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/138770
推荐阅读
相关标签
  

闽ICP备14008679号