赞
踩
dpkg -l | grep mysql
若没有安装则不会出现任何提示,如下图是安装过的。
sudo apt install mysql-server
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;
CREATE DATABASE IF NOT EXISTS node DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
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端口、用户名、密码
这里就是新建的数据库
附上:
- root@Eth002:/home/caojun/FISCO/WeBASE-Node-Manager/dist/script# mysql_secure_installation
-
- Securing the MySQL server deployment.
-
- Connecting to MySQL using a blank password.
-
- VALIDATE PASSWORD PLUGIN can be used to test passwords
- and improve security. It checks the strength of password
- and allows the users to set only those passwords which are
- secure enough. Would you like to setup VALIDATE PASSWORD plugin?
-
- Press y|Y for Yes, any other key for No: N
- Please set the password for root here.
-
- New password:
-
- Re-enter new password:
- 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. This is intended only for
- testing, and to make the installation go a bit smoother.
- You should remove them before moving into a production
- environment.
-
- Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
- Success.
-
-
- 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) : n
-
- ... skipping.
- By default, MySQL comes with a database named 'test' that
- anyone can access. This is also intended only for testing,
- and should be removed before moving into a production
- environment.
-
-
- Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
-
- ... skipping.
- 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
- Success.
-
- All done!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。