环境:
系统:Ubuntu18.0
数据库:mysql-8.0
一:安装数据库
Gogs支持mysql/db2/sqlite等数据库,这里用mysql
也可以只装mysql-server ,建议mysql-client也装上
sudo apt-get install mysql-client
sudo apt-get install mysql-server
启动mysql服务
service mysql start
配置mysql
1.配置mysql服务器,初次安装时,mysql没有密码,为用户添加密码.ps已有数据库的可以忽略此步骤.
mysql -u root -p
Enter password: #直接回车
mysql> use mysql # 选择名为mysql的数据库
mysql> update user set Password=password('123456') where User='root' # 更新root密码
2.填坑 新安装的数据库,坑太多了,特别是你安装mysql8.0,坑更大
第1步通常都不会顺利的,两个问题,登不进数据库,错误1:ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’
更新root密码的sql报错,执行不了. 错误2:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(‘000000’) where user=‘root’’ at line 1
①解决怎么登录数据库
root用户进不去,换个用户.
安装mysql的时候系统自耦东创建了一个用户.打开/etc/mysql/debian.cnf文件
sudo cat /etc/mysql/debian.cnf
如下:
# Automatically generated for Debian scripts. DO NOT TOU