当前位置:网站首页>阿里云ECS服务器搭建Mysql数据库
阿里云ECS服务器搭建Mysql数据库
2022-06-10 12:14:00 【大能人powerman】
阿里云ECS服务器搭建Mysql数据库
一、服务器系统:
Alibaba Cloud Linux 3.2104 LTS 64位
二、服务器文件夹创建
【说明】:由于服务器为新申请,故服务器为空白服务器。
1. 创建software文件夹
【说明】:用于存放Mysql及其他软件
【操作】:
首先进入root目录下
cd /root创建opt文件夹
mkdir opt创建softwar文件夹
mkdir software
2.创建data文件夹
【说明】:用于存放数据
【操作】:
首先进入home目录下
cd /home创建data文件夹
mkdir data【注】:如果创建在/root/opt下,data是没有操作权限的。
Mysql数据库搭建
下载地址:
https://dev.mysql.com/downloads/mysql/5.7.html#downloads

a.将下载后的mysql压缩包上传至服务器上
cd /root/opt/softwaresu rz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gzb.解压mysql压缩包
tar -xzvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gzc.移动并重命名
mv mysql-5.7.37-linux-glibc2.12-x86_64 /root/opt/software/mysqld.创建mysql用户组和用户
sudo groupadd mysqle.修改权限
sudo useradd -r -g mysql mysqlf.创建数据目录
sudo mkdir -p /home/data/mysqlg.赋予权限
sudo chown mysql:mysql -R /home/data/mysqlh.配置my.cnf
sudo vim /etc/my.cnf【my.cnf内容】:
[mysqld] bind-address=0.0.0.0 port=3306 user=mysql basedir=/root/opt/software/mysql datadir=/home/data/mysql socket=/tmp/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks character_set_server=utf8mb4 symbolic-links=0 explicit_defaults_for_timestamp=true # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/home/data/mysql/mysql.err pid-file=/homne/data/mysql/mysql.pid # # include all files from the config directory # !includedir /etc/my.cnf.di.初始化数据库
进入到mysql的bin目录:
cd /root/opt/software/mysql/bin初始化:
sudo ./mysqld --defaults-file=/etc/my.cnf --basedir=/root/opt/software/mysql/ --datadir=/home/data/mysql/ --user=mysql --initializej.查看密码[mysql初始化密码]:
cat /home/data/mysql/mysql.err

二、启动Mysql
a.先将mysql.server放置到/etc/init.d/mysql中
cp /root/opt/software/mysql/support-files/mysql.server /etc/init.d/mysqlb.启动:
service mysql startc.查看mysql进程
ps -ef|grep mysql

d.至此Mysql安装成功
三、修改密码
a.首先登录mysql使用是随机生成的密码
cd /root/opt/software/mysql/binb.登录:
./mysql -u root -p

c.修改密码:
SET PASSWORD = PASSWORD('123456'); ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; FLUSH PRIVILEGES;

Linux设置mysql允许远程连接
1.登录mysql,命令:
mysql -u root -p,然后输入密码即可。2.使用mysql库:
use mysql;
- 3.查询信息:
select user,host from user;【说明】:host字段中,localhost表示只允许本机访问,要实现远程连接,可以将root用户的host改为%,%表示允许任意host访问,如果需要设置只允许特定ip访问,则应改为对应的ip。
Database changed mysql> select user,user,host from user; +---------------+---------------+-----------+ | user | user | host | +---------------+---------------+-----------+ | root | root | % | | mysql.session | mysql.session | localhost | | mysql.sys | mysql.sys | localhost | +---------------+---------------+-----------+ 3 rows in set (0.00 sec)4.修改root用户的host字段,命令
update user set host="%" where user="root";5.使本次修改立即生效,命令
flush privileges6.最后,在windows下的Navicat中远程连接
边栏推荐
- 【限时】,干货满满
- Shadergraph - 303 swaying grass
- Clip usage
- Amateurs don't ask for help, drag and drop for 30 seconds to make the cover image
- ShaderGraph——303摇曳的小草
- Driver. JS - open source and independent interactive guidance tool library for web novices, powerful and highly customizable
- Add line number field to SQL query results - sqlserver
- Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
- 【严选】,真题解析
- Get enumeration values through reflection
猜你喜欢

Zipoutputstream use

4.25 million budget bidding: centralized procurement of onsite maintenance services for Oracle, teledb, telepg and other core system databases of Jiangsu Telecom

JS converts timestamp to normal time format

Minimalist random music player

(六)类和对象,对象初始化和拷贝构造函数(3)

Learning of cc2642r Bluetooth MCU chip

交出 Firehouse 数据库访问权:推特准备满足马斯克要求

Web design and development, efficient web development

H5弹出提示层-上下左右居中

(七)深拷贝与浅拷贝
随机推荐
ShaderGraph——303摇曳的小草
STM32F407学习笔记(1)-EXTI中断事件与NVIC寄存器
IO file stream repeat read
MAX3051的can芯片的学习
Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
Driver. JS - open source and independent interactive guidance tool library for web novices, powerful and highly customizable
JS converts timestamp to normal time format
Stm32f407 learning notes (1) -exti interrupt event and NVIC register
使用Joern处理大量文件,生成PDG速度很慢的解决方法
【云图说】每个成功的业务系统都离不开APIG的保驾护航
ShaderGraph——301跳动的小球
4.25 million budget bidding: centralized procurement of onsite maintenance services for Oracle, teledb, telepg and other core system databases of Jiangsu Telecom
print(net) vs. net. parameters vs. net. named_ parameters
js使用iCheck插件监听获取CheckBox的值
C语言最佳实践之库文件介绍(上)
Get enumeration values through reflection
国际档案日|瀚高数据库以科技赋能数字档案建设
C语言最佳实践之库文件介绍(下)
Traversing object properties of unknown type
Dom4j parsing XML