linux下mysql安装教程
时间: 2023-09-23 12:05:11 浏览: 108
在Linux下安装MySQL的步骤如下:
1. 首先,将mysqld服务添加到系统中。进入MySQL安装目录,执行以下命令:
```
cp -a ./support-files/mysql.server /etc/init.d/mysql
```
2. 授权MySQL服务文件并设置权限:
```
chmod x /etc/init.d/mysql
chkconfig --add mysql
```
3. 创建MySQL数据目录。在MySQL安装目录下执行以下命令:
```
mkdir data
```
4. 创建MySQL用户组和用户。执行以下命令:
```
groupadd mysql
useradd -g mysql mysql
```
5. 授权MySQL文件夹给MySQL用户。执行以下命令:
```
chown -R mysql.mysql /usr/local/mysql
```
6. 初始化MySQL信息。执行以下命令:
```
cd /usr/local/mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
```
7. 启动MySQL服务。执行以下命令:
```
/etc/init.d/mysql start
```
8. 登录MySQL并修改root密码。执行以下命令:
```
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
```
以上是在Linux下安装MySQL的步骤。请按照上述步骤进行操作,即可成功安装MySQL。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Linux下安装MySql详细教程](https://blog.csdn.net/qq_34383510/article/details/125220644)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文