The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 6,643β€…    Votes:  3β€…    βœ… Solution
Tags: server   permissions   mysql  
Link: πŸ” See Original Answer on Ask Ubuntu πŸ”—

URL: https://askubuntu.com/q/1045314
Title: I cannot use MySql as normal user in Ubuntu 18.04
ID: /2018/06/10/I-cannot-use-MySql-as-normal-user-in-Ubuntu-18.04
Created: June 10, 2018    Edited:  January 2, 2022
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


From this tutorial you need to create a database and user to use mySQL.

To create a MySQL database and user, follow these steps

At the command line, log in to MySQL as the root user:

mysql -u root -p

Type the MySQL root password, and then press Enter.

To create a database user, type the following command. Replace username with the user you want to create, and replace password with the user’s password:

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';

This command grants the user all permissions. However, you can grant specific permissions to maintain precise control over database access. For example, to explicitly grant the SELECT permission, you would use the following command:

GRANT SELECT ON *.* TO 'username'@'localhost';

For more information about setting MySQL database permissions, please visit MySQL - 13.7.1.6 GRANT Statement.

Type \q to exit the mysql program.

To log in to MySQL as the user you just created, type the following command. Replace username with the name of the user you created above:

mysql -u username -p

Type the user’s password, and then press Enter.

To create a database, type the following command. Replace dbname with the name of the database that you want to create:

CREATE DATABASE dbname;

To work with the new database, type the following command. Replace dbname with the name of the database you created above:

USE dbname;

You can now work with the database. For example, the following commands demonstrate how to create a basic table named example, and how to insert some data into it:

CREATE TABLE example ( id smallint unsigned not null auto_increment, name varchar(20) not null, constraint pk_example primary key (id) );
INSERT INTO example ( id, name ) VALUES ( null, 'Sample data' );

Much more can be found in the tutorial linked above such as:

More Information

To view the official MySQL documentation, please visit MySQL 8.0 Reference Manual.

⇧ Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin How to make speaking clock (via cron and festival tts) work while playing music  β‡©