Article / 文章中心

linux下配置mysql 以及 linux下开启守护进程

发布时间:2021-12-06 点击数:412

linux下mysql的安装配置

更新数据源

sudo apt-get update sudo apt-get upgrade


安装mysql

sudo apt-get install mysql-server


启动mysql

service mysql start


进入mysql

sudo mysql


更改mysql权限

mysql> use mysql; mysql> UPDATE mysql.user SET authentication_string=password('你想设置的密码') WHERE User='root' AND Host ='localhost'; mysql> UPDATE user SET plugin="mysql_native_password"; mysql> flush privileges; mysql> exit;

重新尝试进入mysql


mysql -u root -p

输入密码就可以了。


linux下配置守护进程服务

编写脚本文件

进入服务路径


cd /etc/systemd/system

然后进行一个脚本的编写

比如一个 helloworld.service

sudo vim helloworld.service


填写以下内容


[Unit] Description = OA-System After = network.target  [Service] ExecStart=/home/ubuntu/hello/main  # 这里main就是你的二进制执行文件 ExecReload=/home/ubuntu/hello/main WorkingDirectory=/home/ubuntu/hello StandardOutput = inherit StandardError = inherit Restart=always  [Install] WantedBy=default.target


运行

sudo systemcli enable oa.service  # 允许开机自启 sudo systemcli start oa.service # 守护进程的方式启动