问题
I tried to below OS installed on my laptop
Mint version 19,
Code name : Tara,
PackageBase : Ubuntu Bionic
Cinnamon (64-bit)
I have installed mysql-server using below command:
xxxxxxx:~$ sudo apt-get install mysql-server
During this installation I was not prompted to enter any root password. TO see if installation was successful, I ran below command:
xxxxxxxxxx:~$ mysql -V
mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using EditLine wrapper
xxxxxxxxxx:~$ sudo service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-09-30 21:59:42 EDT; 9s ago
Main PID: 3518 (mysqld)
Tasks: 27 (limit: 4915)
CGroup: /system.slice/mysql.service
└─3518 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Sep 30 21:59:41 globallogic systemd[1]: Starting MySQL Community Server...
Sep 30 21:59:42 globallogic systemd[1]: Started MySQL Community Server.
As I was not prompted to set any root password, I thought of setting root password.
xxxxxxxx:~$ mysqladmin -u root password
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost''
xxxxxxxx:~$ sudo mysqladmin -u root password
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
1. Why I can't be able to use "mysqladmin" command without being logged in as root?
2. How to fix the warning for mysqladmin set root password? ANd can I be able to use that password inside mysql workbench in future if decide to use it?
After setting root password(assuming that's the right way to set it) , I have installed mysql-workbench
xxxxxxx:~$ sudo apt-get install mysql-workbench
When I launch mysql workbench, I can't be able to connect to user:root using hostname: localhost and port: 3306 and password set using mysqladmin command.
I also tried to use hostname: 127.0.0.1 but that didn't work either.
3. How to fix mysql-workbench issue?
I looked on internet to find answers for this and tried multiple solutions, but none worked.
Hoping to get cleaner answer here.
回答1:
Note: Installed mysql workbench version 6.3 and mysql server version 5.7
Before installing I cleaned any mysql files/references I had on my linux machine.
sudo apt-get remove --purge mysql* sudo apt-get purge mysql* sudo apt-get autoremove sudo apt-get autoclean sudo apt-get remove dbconfig-mysql
Below steps worked fine for me -
Go to the download page for the MySQL APT repository at https://dev.mysql.com/downloads/repo/apt/ and downloaded mysql-apt-config_0.8.10-1_all.deb
Made sure everything is up to date.
xxxxxxxxx:~/Downloads$ sudo apt-get update
- installed downloaded deb file.
xxxxxxxxx:~/Downloads$ sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb Selecting previously unselected package mysql-apt-config. (Reading database ... 273762 files and directories currently installed.) Preparing to unpack mysql-apt-config_0.8.10-1_all.deb ... Unpacking mysql-apt-config (0.8.10-1) ... Setting up mysql-apt-config (0.8.10-1) ... Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config) OK
during this step chose mysql server version 5.7
- After this ran sudo apt-get update and then ran
xxxxxxxxx:~/Downloads$ sudo apt-get install mysql-server
during this step, I was prompted to to set root password. Ended up setting root password as 'pa$$word'
- After installation is successful checked status
xxxxxxxxx:~/Downloads$ sudo service mysql status ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2018-10-01 15:31:19 EDT; 29s ago Main PID: 23029 (mysqld) Tasks: 27 (limit: 4915) CGroup: /system.slice/mysql.service └─23029 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Oct 01 15:31:18 systemd[1]: Starting MySQL Community Server... Oct 01 15:31:19 systemd[1]: Started MySQL Community Server.
- Then tried to check if I can go to mysql prompt.
xxxxxxxx:~/Downloads$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.23 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> quit Bye
- Then installed mysql workbench using below command
xxxxxxxxxxx:~/Downloads$ sudo apt-get install mysql-workbench
Launched mysql workbench from start menu on linux mint 19. Here Server connection has parameteres like hostname: 127.0.0.1 , port:3306, Username: root, password: pa$$word. The tested connection - successful.
double clicked connection and it launched instance fine.
来源:https://stackoverflow.com/questions/52584176/linux-mint-mysql-server-and-mysql-workbench-installation-and-setup-issue