Connect to mysql server without sudo

9 Answers 9

Only the root user needs sudo requirement to login to mysql. I resolved this by creating a new user and granting access to the required databases:

now newuser can login without sudo requirement:

You need to change algorithm. Following work for me,

You can use the same ROOT user, or a NEW_USER and remove the SUDO privileges. Below example shows how to remove connect using ROOT, without SUDO.

Connect to MY-SQL using SUDO

Delete the current Root User from the User Table

Create a new ROOT user (You can create a different user if needed)

Grant permissions to new User (ROOT)

Flush privileges, so that the Grant tables get reloaded immediately. (Why do we need to flush privileges?)

Now it’s all good. Just in case, check whether a new root user is created.

Exit mysql. (Press CTRL + Z). Connect to MySQL without SUDO

Configuration

Replace 192.168.0.5 with the appropriate address, which can be determined via ip address show .

After making a configuration change, the MySQL daemon will need to be restarted:

Advanced configuration

Creating a tuned configuration

There are a number of parameters that can be adjusted within MySQL’s configuration files that will allow you to improve the performance of the server over time.

Many of the parameters can be adjusted with the existing database, however some may affect the data layout and thus need more care to apply.

First, if you have existing data, you will need to carry out a mysqldump and reload:

Once the dump has been completed, shut down MySQL:

It’s also a good idea to backup the original configuration:

Next, make any desired configuration changes.

Then delete and re-initialise the database space and make sure ownership is correct before restarting MySQL:

The final step is re-importation of your data by piping your SQL commands to the database.

Once that is complete all is good to go!

MySQL Tuner

Then once its been installed, run:

Steps for a Fresh Installation of MySQL

Follow the steps below to install the latest GA release of MySQL (from the MySQL 5.7 series currently) with the MySQL Yum repository:

Selecting a Release Series

When using the MySQL Yum repository, the latest GA series (currently MySQL 5.7) is selected for installation by default. If this is what you want, you can skip to the next step, Installing MySQL.

Besides using yum-config-manager command, you can also select a release series by editing manually the /etc/yum.repos.d/mysql-community.repo file. This is a typical entry for a release series’ subrepository in the file:

You should only enable subrepository for one release series at any time. When subrepositories for more than one release series are enabled, the latest series will be used by Yum.

Verify that the correct subrepositories have been enabled and disabled by running the following command and checking its output:

Starting the MySQL Server

Start the MySQL server with the following command:

This is a sample output of the above command:

You can check the status of the MySQL server with the following command:

This is a sample output of the above command:

Installing Additional MySQL Products and Components with Yum

Install any packages of your choice with the following command, replacing package-name with name of the package:

For example, to install MySQL Workbench:

To install the shared client libraries:

4 Answers 4

The solution is to provide a password for the root mysql account (if you’ve not done so already). The error message you’re receiving is because a password is required, and you have not provided it. Reset root password with:

or if you’d already set a root password (which I doubt, otherwise you wouldn’t be able to log in via sudo) then it would be

Mysql users are not linked with unix users, unlike postgres.

For either query, first login as root by using sudo mysql

For MySQL or MariaDB >= 10.2:

For others who may be using MariaDB ALTER USER ), you’ll want to run this query:

Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Output looks like this:

Please try the below command:

[password] — type the password you have set while installing mysql.

Start MySQL Server on Windows

On Windows, you can start the MySQL Server using the mysqld program as follows:

First, open the Run dialog by pressing Windows+R keyboards:

Second, type cmd and press Enter :

Third, type mysqld and press Enter :

If the bin folder is not in the Windows path environment, you can navigate to the bin folder e.g., C:Program FilesMySQLMySQL Server 8.0bin and use the mysqld command.

In this tutorial, you have learned how to start MySQL Server on Windows and Linux.

Utilisation

Démarrage

Pour démarrer le serveur MySQL, tapez la commande suivante dans un terminal:

Redémarrage

Pour redémarrer le serveur MySQL, tapez la commande suivante dans un terminal:

Arrêt

Pour arrêter le serveur MySQL, tapez la commande suivante dans un terminal:

Rechargement de la configuration

Pour que MySQL prenne en compte les modifications de sa configuration, commande suivante dans un terminal:

Forcer la prise en compte de la nouvelle configuration

Pour forcer MySQL à recharger ses fichiers de configuration, commande suivante dans un terminal:

Connaître la version

Il est parfois utile de connaître la version installée:

Quelques requêtes SQL

Toutes ces commandes sont à entrer dans le prompt de MySQL une fois connecté au serveur. (Voir comment lancer la console MySQL ci dessus.)

Ссылка на основную публикацию
Adblock
detector