Asterisk not connecting to realtime database

Hi, I have configured a realtime database named ‘asterisk’ in mysql on my ubuntu server and I am running asterisk on the same server but everytime it shows me the same error : “Invalid Database specified ‘asterisk’”. I made some changes such as in the res_config_mysql file I changed [general] to [asterisk]. Now I am getting a different error which is " Failed to connect to database server asterisk on 127.0.0.1 ".

my database has only 1 table as of now which is ps_endpoints( id, transport, aors, auth, context, disallow, allow, direct_media)

extconfig.conf

[settings]
ps_endpoints => mysql,asterisk,ps_endpoints
res_config_mysql.conf


[asterisk]
dbhost = 127.0.0.1
dbname = asterisk
dbuser = root
dbpass = walkover
dbport = 3306
sorcery.conf

[res_pjsip]
endpoint=realtime,ps_endpoints

[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips

Hi Tanya,

That table seems quite light on columns (would have expected many more). Did you create this table manually or use alembic?

Can you access that db from the command line using those creds while logged in with your run user asterisk (or which ever user runs asterisk)? mysql logs might show something a bit more descriptive too.

Regards

I have created the table manually.
And my mysql logs is showing " Acces denied for root@localhost"

Hey Tanya, not sure how your database has been setup but it sounds like a mysql issue rather than Asterisk directly. Search mysql root@localhost and it will explain that this default behaviour won’t work without some changes - using the root user this way is generally considered bad practice.

I think you will be hitting issues with that manually created tabled even if you managed to login, it would be better to follow the guide and not use root but a new user such as asterisk:
https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime#SettingupPJSIPRealtime-CreatingtheMySQLDatabase

Hi thank you so much, my problem got resolved after I created a new user and gave it all the priviliges on my database. But it seems a bit confusing to me as a root user already has all priviliges over the database so how does making a new user and giving him priviliges which the root user already have could make any difference