以 root 身份启动 Mysql

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1427010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:06:17  来源:igfitidea点击:

Starting Mysql as root

mysql

提问by shantanuo

I have started mysql on my test server as a root. I have added

我已经在我的测试服务器上以 root 身份启动了 mysql。我已经添加了

user=root 

line in my.cnf Since I want the test server to upgrade to production server, I will like to comment this line and restart.

my.cnf 中的一行由于我想让测试服务器升级到生产服务器,所以我想注释这一行并重新启动。

Are there any side effects? data loss expected?

有没有什么副作用?预计数据丢失?

采纳答案by longneck

first step would be to back up your data directory.

第一步是备份您的数据目录。

after you've done that, go ahead and make the change. just make sure that you have a user named mysql (or specify a different one explicitly) and that they have appropriate permissions to the data directory.

完成后,继续进行更改。只需确保您有一个名为 mysql 的用户(或明确指定一个不同的用户)并且他们对数据目录具有适当的权限。

this is a pretty safe operation to do and should result in no loss of functionality or data. but just in case, you do have the backup!

这是一个非常安全的操作,应该不会导致功能或数据丢失。但以防万一,您确实有备份!

回答by pavium

The 'root' user for MySQL is NOT the same as the root user for logging in to the computer, so there should be no side effects provided you GRANT the appropriate rights to the mysql user on the production server.

MySQL 的“root”用户与登录计算机的 root 用户不同,因此如果您向生产服务器上的 mysql 用户授予适当的权限,应该不会有副作用。

That is the user mentioned in

那是提到的用户

$ mysql -u user -p password db_name

which couldshare a name with a user logged in to the computer, but doesn't have to.

可以与登录到计算机的用户共享一个名称,但不是必须的。

EDIT: note - an ordinary user can start mysql as root if the correct password is used in the command above. This won't be the same as root'spassword, if you know what I mean.

编辑:注意 - 如果在上面的命令中使用了正确的密码,普通用户可以以 root 身份启动 mysql。如果您知道我的意思,这将与root 的密码不同。

If it's not clear you should definitely familiarise yourself with the meaning of 'root' in a MySQL context.

如果不清楚,您一定要熟悉 MySQL 上下文中“root”的含义。

回答by Vaibhav Joshi

  1. When you start your mysql shell, enter it as the root as

    C:\xampp\mysql\bin\mysql.exe -u root -p [password if any];

  2. If you don't enter any password after '-p' in the command, it will prompt you for one. Just press enter if you do not have any password (by default) or enter the password if you've set one.

  3. for checking whether you have a password or not, got to the http://localhost/phpmyadmin/

    • you can find the root user credentials.
  4. Once you are connected, just check all the databases as SHOW DATABASES; you will get a list of default databases already existing. This will be the final confirmation.

  1. 当您启动 mysql shell 时,以 root 身份输入它

    C:\xampp\mysql\bin\mysql.exe -u root -p [密码如果有];

  2. 如果您在命令中的“-p”后没有输入任何密码,它会提示您输入密码。如果您没有任何密码(默认情况下),只需按 Enter 键,或者如果您设置了密码,请输入密码。

  3. 要检查您是否有密码,请访问 http://localhost/phpmyadmin/

    • 您可以找到 root 用户凭据。
  4. 连接后,只需将所有数据库检查为 SHOW DATABASES;您将获得已存在的默认数据库列表。这将是最后的确认。

回答by Andrew

To log in to MySQL as the root user, all I needed to do was:

要以 root 用户身份登录 MySQL,我需要做的就是:

mysql -u root