安装mysql

mysql是非常常用的关系型数据库,在安装过程中时常有坑,特别是我经常重装系统,囧。

环境:
ubuntu18.04.3

##安装mysql5.7.28
sudo apt install mysql-client mysql-server
##登录mysql
sudo mysql -uroot -p
Enter password: 

修改密码

mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "yourpassword";
Query OK, 0 rows affected, 1 warning (0.00 sec)

##新建database
mysql> CREATE DATABASE andrew;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON weixx.* TO mac@"%" IDENTIFIED BY "python";
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit;
Bye

遇到的坑:
macos10.15
mariadb

mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

按照教程,可能是service未开启。
开启mysql service

mysql.server start
Starting MariaDB
.191201 18:02:08 mysqld_safe Logging to '/usr/local/var/mysql/macbook.err'.
191201 18:02:08 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
/usr/local/bin/mysql.server: line 264: kill: (57974) - No such process
 ERROR! 

重新安装mysql

brew install mysql
touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied
touch: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/FETCH_HEAD: Permission denied
touch: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/FETCH_HEAD: Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
error: could not lock config file .git/config: Permission denied
Error: Cannot install mysql because conflicting formulae are installed.
  mariadb: because mysql, mariadb, and percona install the same binaries.

Please `brew unlink mariadb` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side effects in the
resulting software.

已经安装了mariadb

brew unlink mariadb
brew install mysql

安装成功!!!!

然后登录的时候,一样报错,然后重启服务,可以登录,不是系统密码。

mysql -uroot -p    
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
andrew@1macbook:~#mysql.server start 
Starting MySQL
.. SUCCESS! 
andrew@macbook:~#mysql -uroot -p   

直接enter进去,

按照上面的方式修改密码,一直报错,

要这样

ALTER USER "root"@"localhost" IDENTIFIED  BY "大小写复杂的密码";
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值