LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to configure MYSQL .. (https://www.linuxquestions.org/questions/linux-server-73/how-to-configure-mysql-608728/)

lin_myworld 12-23-2007 11:09 AM

How to configure MYSQL ..
 
[FONT="Times New Roman"]I got the solution to my problem on my own.
:cool:

Check it out here :
How to setup MYSQL in Suse.

What i m using:
Suse 10.2
Apache2 webserver
MYSQL Ver 14.12 Distrib 5.0.26, for suse-linux-gnu (i686)

To start APACHE2 server
In terminal type
Code:

/etc/init.d/apache2 start
and similarly To start MYSQL server type:
Code:

/etc/init.d/mysql start
Now if ur running mysql first time you should set the root superuserpassword of mysql which is by default empty.

Now, My Problem was :

Whenever i want to create a database using sql command and type mysql in terminal it prints the following message.

Code:

suse:~ # mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

manni is the other user in my pc. i login in as manni and then type mysql it works. terminal prompt changes to mysql but it does not have the privilege to create,remove or alter databases.Lter i founnd that the anonymous login was is on which is by default for testing.It should be switched of for security purposes. mysql has also a defult database called test which should also be deleted.

so,
1)The root superuser is never allowed to access mysql through terminal due to security reasons but u can enable it ... see below for it.

2)however root is given aceess to all the databses through localhost. for eg.when i was trying to install a forum in my webserver in installation process it asked for user and user password.and for all databases root user and password works.

3)Now u will be wondering what the use of root password then if it cannot access mysql through terminal and cannot use sqlcommands.but remember root can acess all command through localhost.

take a example:
I created a user xyz and assign it to database php and give it only the privilge of queryin the database i.e. using only SELECT command and used this user information while installing a forum ..the followin error occured.

Code:

A fatal and unrecoverable database error has occurred. This may be because the specified user does not have appropriate permissions to CREATE TABLES or INSERT data, etc. Further information may be given below. Please contact your hosting provider in the first instance for further assistance.
The best practice involved while installing database driven applications is to create a database and assign it to user and give it to the basic privilege of creating,altering,deleting,querying and modifying tables. rather than using root due to security purposes.

How to enable root to access commands through terminal and to remove the anonymous user settings and the test database
just run the mysql_secure_installation command in terminal and follow on screen steps.

To assign user to a particular database and asssign him the privileges.
run the mysql_setpermission command in terminal and enter the root super userpassword u will get the folowing screen:
Code:

######################################################################
## Welcome to the permission setter 1.3 for MySQL.
## made by Luuk de Boer
######################################################################
What would you like to do:
  1. Set password for an existing user.
  2. Create a database + user privilege for that database
    and host combination (user can only do SELECT)
  3. Create/append user privilege for an existing database
    and host combination (user can only do SELECT)
  4. Create/append broader user privileges for an existing
    database and host combination
    (user can do SELECT,INSERT,UPDATE,DELETE)
  5. Create/append quite extended user privileges for an
    existing database and host combination (user can do
    SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,
    LOCK TABLES,CREATE TEMPORARY TABLES)
  6. Create/append database administrative privileges for an
    existing database and host combination (user can do
    SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,
    CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS)
  7. Create/append full privileges for an existing database
    and host combination (user has FULL privilege)
  8. Remove all privileges for for an existing database and
    host combination.
    (user will have all permission fields set to N)
  0. exit this program

Make your choice [1,2,3,4,5,6,7,0]:

make ur choice and do whatever u want to do.


At last, remember never share ur root superuser password with anyone because it has all privileges and it sets other privileges. and through it one can easily hack ur database.

Plz leave reply post if helps u in anyway and ask questions if there r doubts. I love to do experimenting all around. and if i got anything new i will sure update this post.

All the things i learnt while experimenting when i got stuck wid my problem..thats the most xciting part of linux u learn while xperimenting..

jschiwal 12-23-2007 11:18 AM

I would recommend reading the manual. There is a section on securing mysql after the initial setup. ( On openSUSE 10.2 the mysql package supplies the manual in /usr/share/doc/packages/mysql) For openSUSE 10.3, you need to download the manual from the mysql site.


All times are GMT -5. The time now is 03:25 AM.