mariaDB官方安装步骤
Here are the commands to run to install MariaDB 10.5 from the MariaDB repository on your Ubuntu system:
sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] [http://mariadb.mirror.iweb.com/repo/10.5/ubuntu](http://mariadb.mirror.iweb.com/repo/10.5/ubuntu) focal main'
Once the key is imported and the repository added you can install MariaDB 10.5 from the MariaDB repository with:
sudo apt update
sudo apt install mariadb-server
安装
-下载安装
sudo apt install mariadb-server
-连接、测试
sudo mysql -u root -p
-安装数据库实例
sudo mysql_secure_installation
启动&重启关闭(两种方式)
-查看状态
sudo systemctl status mysql
sudo service mysql status
-启动
sudo systemctl start mysql
sudo service mysql start
-重启
sudo systemctl restart mysql
sudo service mysql restart
-关闭
sudo systemctl stop mysql
sudo service mysql stop
配置
-登录
sudo mysql -u root -p #输入root 用户密码
-创建远程登录用户 ,
格式:create user ‘用户名’@’%’ identified by ‘密码’;
create user 'us'@'%' identified by '123';
-授权(如果权限不足)
GRANT ALL PRIVILEGES ON *.* TO 'us'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
FLUSH PRIVILEGES;
不要开放root 远程登录权限
-查看监听
netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
如果显示 监听端口 是127.0.0.1:3306 那么其他计算机无法连接
-修改配置
vi /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 127.0.0.1 #注释掉这一行
修改后记得重启mysql服务
重启后显示
tcp6 0 0 :::3306 ::😗 LISTEN
此时就可以远程访问mariadb了
-远程访问
直接登录
mysql -h localhost -u us -p 123 #输入us 用户密码123
用客户端工具登录
sqlyog navicat hs
原文:https://blog.csdn.net/zdyah/article/details/82354346
创建数据库
CREATE DATABASE IF NOT EXISTS databasename
CHARACTER SET utf8 COLLATE
utf8_general_ci;