For a start, we have to have installed the mysql server. If you have not yet installed, install it using the package manager, or manually, by using commands (depending on distro):
In Debian/Ubuntu:
$ sudo apt-get install mysql-server
In RedHat/Fedora and their derivatives:
# yum install mysql-server
The Zenwalk:
# netpkg mysql-server
After you install the required packages, run the mysql server command (depending on the package):
#/etc/rc.d/rc.mysqld start
or
#/etc/init.d/mysqld start
or
# service mysqld start
Then carry out the connection to the MySQL server using the root account:
$ mysql-u root
Attention! By default, when you connect to the database as root from localhost, a password is not required.
If, during the installation of the mysql server you assigned to the user any password, then you can connect to the mysql server, using the key-p:
$ mysql-u root-p
Enter password:
After a successful connection, run the create database command:
MySQL create database > testbase;
Then we create a user baseuser to connect to the database, and assign it a password ‘ userpasswd ‘:
MySQL > grant usage on *. * to @ localhost identified by ‘ baseuser ‘ userpasswd ‘;
And, finally, assign all privileges (rights) to the testbase user baseuser:
MySQL grant all privileges on > testbase. * to @ localhost baseuser;
Character * (an asterisk) means “all tables in the database.”
All, we have coped with this task.
Now let’s check the connection of the user database baseuser testbase:
$ mysql-u-p baseuser ‘ userpasswd ‘ testbase
Leave a Reply